Description
This JavaScript hook can be used to filter new Repeater Field groups before they are added.
Usage
gform.addFilter( 'gform_repeater_item_pre_add', function ( clone, item ) {
// do stuff
return clone;
} );
Parameter | Type | Description |
---|---|---|
clone | Javascript Object | The group of Repeater Field items. |
item | Javascript Object | The group of Repeater Field items before being cloned and the inputs cleared. |
Example
This example shows how you can set the value of the second input in a Repeater Field group.
gform.addFilter('gform_repeater_item_pre_add', function(clone, item) {
// do stuff
clone.find('.gfield_repeater_cell:eq(1) input').val('your new value');
return clone;
});
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in js/gravityforms.js.