Forum Replies Created

Viewing 1 replies (of 1 total)
  • Amity

    (@amitybinkertorg)

    This is happening because the form data is only saved to the database when the page changes, which is prevented by the validation errors. When the page is redrawn and pre-populated with the data from the database after a validation error, it doesn’t get any of the new entries on the page.

    I think you can fix this by adding a hook on the “gform_validation” action to save the form data to the database. I think WP’s update_option() function handles cleaning up the data before it is added to the database, but you’ll want to check that out yourself – especially where the validation has failed.

    Would be best to wait for the original author to update the plugin for this instance, but you can try this out by adding the following code to persistent_multipage_forms.php in the plugin directory (will be overwritten with any plugin updates!):

    add_action("gform_validation", "validate_and_save_gf_data");
    
    function validate_and_save_gf_data($validation_result) {
    	if ($validation_result['isValid'])
    		return $validation_result;
    
    	$form = $validation_result["form"];
    	if ($form['isPersistent']) {
    		if (is_user_logged_in()) {
    			$option_key = getFormOptionKeyForGF($form);
    			update_option($option_key, json_encode($_POST));
    		}
    	}
    	return $validation_result;
    }
Viewing 1 replies (of 1 total)