Description
The gform/conditional_logic/field_action/end event triggers when Gravity Forms finishes applying a conditional logic action (show or hide) to a target field.
Usage
document.addEventListener( 'gform/conditional_logic/field_action/end', function( event, formId, action, targetId, defaultValues, isInit ) {
// Custom logic here.
});
Parameters
| Parameter | Type | Description |
|---|---|---|
| event | event | The event that triggered the conditional logic action. |
| formId | int | The ID of the form. |
| action | string | The action applied to the target field: show or hide. |
| targetId | string | The ID of the target field or section the action was applied to. |
| defaultValues | object | The default value(s) restored or applied to the target field, if any. |
| isInit | bool | Whether this run is part of the initial page-load conditional logic evaluation, as opposed to a later, user-triggered evaluation. |
Examples
Remove stale coupon rows when a field is hidden by conditional logic.
document.addEventListener( 'gform/conditional_logic/field_action/end', function ( event ) {
var action = event.detail.action,
targetId = event.detail.targetId,
isInit = event.detail.isInit;
if ( ! isInit && action === 'hide' ) {
var target = document.querySelector( targetId ),
couponItems = target.querySelectorAll( 'tr.gf_coupon_item' );
if ( couponItems.length ) {
couponItems.forEach( function ( item ) {
item.remove();
} );
target.querySelectorAll( 'input[type=hidden]' ).forEach( function ( input ) {
input.value = '';
input.dispatchEvent( new Event( 'change' ) );
} );
}
}
});
Source Code
This event is located in assets/js/src/theme/columns/fixed.js
Since
The event was added in Gravity Forms 3.2