Description
The gform_reset_pre_conditional_logic_field_action JavaScript filter allows developers to prevent the field value being reset to its default value when hidden by conditional logic on the frontend.
Please note fields which are hidden by conditional logic when the form is submitted will not be saved when the entry is saved.
Usage
gform.addFilter('gform_reset_pre_conditional_logic_field_action', function (reset, formId, targetId, defaultValues, isInit) {
// do stuff
return reset;
});
Parameters
| Parameter | Type | Description |
|---|---|---|
reset | boolean | Determines if the field values should be reset to default when the field is hidden. Default is true. |
formId | integer | The ID of the current form. |
targetId | string | The ID selector for the field container (li) in the format #field_{formId}_{fieldId} e.g. #field_10_2. |
defaultValues | string | array | The field default values. |
isInit | boolean | True when the form is initially displayed, otherwise false. |
Examples
Prevent all field values being reset.
The following example shows how you can prevent the field values being reset to default when the field is hidden by conditional logic.
gform.addFilter('gform_reset_pre_conditional_logic_field_action', function (reset, formId, targetId, defaultValues, isInit) {
return false;
});
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in js/conditional_logic.js.
Since
This filter was added in Gravity Forms 2.0.7.1.