Updating form input value after AJAX request is made

Is there a way to update a hidden input value of a gravity form after an AJAX request is finished?
I want to pass a post ID to the hidden input value, nothing fancy.

Also, is there a way to reset gravity form fields and validation errors using a hook or something else?

For both questions, I don’t want to use any plugins.
Thanks!

I managed to update the hidden input after the AJAX request is finished using GFAPI.

$form = GFAPI::get_form(FORM_ID);
$form['fields'][FIELD_NR]['defaultValue'] = AJAX_RESULT;
GFAPI::update_form($form);
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.