gform_field_added

Description

The “gform_field_added” JavaScript filter in Gravity Forms fires after a form field is added, either in the Form Editor or programmatically.

Usage

<script type="text/javascript">
    jQuery(document).on( 'gform_field_added', function( event, form, field ) {
        if( form['id'] == 44 ) {
            // do something specific to this form and field
            alert( "Your new field id is: " + field['id'] );
        }
    } );
</script>

Parameters

Examples

This example uses the gform_admin_pre_render filter to load the hook. A message is displayed when the form id is 44 and new fields are added.


add_action( 'gform_admin_pre_render', 'pre_render_function' );
function pre_render_function( $form ) {
    ?>
    <script type="text/javascript">
        jQuery(document).on("gform_field_added", function(event, form, field){
            if (form['id'] == 44){
                //do something specific to this form and field
                alert("Your new field id is: " + field['id']);
            }
        });
    </script>
    <?php
    return $form;
}

Source Code

This filter is located in “form_editor.js”