Description
This JavaScript hook can be used to filter new List Field rows before they are added.
Usage
gform.addFilter( 'gform_list_item_pre_add', function ( clone ) {
// do stuff
return clone;
} );
Parameters
- clone Javascript Object
The List Field table row.
-
group Javascript Object
The List Field table row before being cloned and the inputs cleared. Available from Gravity Forms 1.9.15.1.
Examples
1. Reset Datepicker Input
This example shows how you can reset a datepicker input so the datepicker will function on the new row.
gform.addFilter( 'gform_list_item_pre_add', function ( clone ) {
clone.find( '.ui-datepicker-trigger' ).remove();
clone.find( 'input.datepicker' ).removeClass( 'hasDatepicker' ).removeAttr( 'id' );
return clone;
} );
2. Set Column Input Value
This example shows how you can set the value of the input in the second column of the new row.
gform.addFilter( 'gform_list_item_pre_add', function ( clone ) {
clone.find( 'td:eq( 1 ) input' ).val( 'your new value' );
return clone;
} );
Placement
Your code snippet can be placed in an HTML field on your form, within script tags, or in a theme custom JavaScript file.
Source Code
This filter is located in js/gravityforms.js