bookmark_bordergform_list_item_pre_add

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.

<script>
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;
} );
</script>

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.

<script>
gform.addFilter( 'gform_list_item_pre_add', function ( clone ) {
    clone.find('td:eq(1) input').val('your new value');
    return clone;
} );
</script>

Placement

Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.

Source Code

This filter is located in js/gravityforms.js