Clear Specific Field Values on Reload
When reloading a form, you may want to preserve the submitted values in some values and remove them in others. This snippet provides a basic mechanism for achieving this. Be sure to enable the “Preserve values from previous submission” form setting in the “Reload Form” section.
Code
Filename: gprf-clear-specific-field-values-on-reload.php
<?php
/**
* Gravity Perks // Reload From // Clear Specific Field Values on Reload
* https://gravitywiz.com/documentation/gravity-forms-reload-form/
*
* When reloading a form, you may want to preserve the submitted values in some values and remove them in others. This
* snippet provides a basic mechanism for achieving this. Be sure to enable the "Preserve values from previous submission"
* form setting in the "Reload Form" section.
*/
// Update "123" to your form ID.
add_filter( 'gprf_disable_dynamic_reload_123', function( $return ) {
function gprf_clear_specific_field_values( $return ) {
// Update "3" to the ID of the field for whose value you would like to clear.
$_POST['input_3'] = '';
remove_filter( 'gform_pre_render', 'gprf_clear_specific_field_values' );
return $return;
}
add_filter( 'gform_pre_render', 'gprf_clear_specific_field_values' );
return $return;
} );
I tried using this snippet on a checkbox, even included the input’s sub-number, like $_POST[‘input_3.1’], but didn’t have success.
Also could not get it to work with multi file inputs.
Hi Isaac,
I can confirm what you’re experiencing. It appears the snippet doesn’t support the checkbox and file uploads fields. I’m forwarding this report to our developers to look into this and see if support can be added for those fields. We’ll update this comment with further information soon.
Best,