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
Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.
See also the JavaScript/jQuery section in this article: Where Do I Put This Code?
Source Code
This filter is located in js/gravityforms.js.