Using Gravity Forms ‘gform_noconflict_scripts’ PHP filter

The gform_noconflict_scripts filter is used to register your script with Gravity Forms, ensuring it gets enqueued in the form editor page when no-conflict mode is enabled.

Usage

add_filter('gform_noconflict_scripts', 'register_script');

Parameters

  • $scripts (array): An array of script handles to be filtered. Add scripts to this array to register them, (i.e. $scripts[] = 'my-script-handle';).

More information

See Gravity Forms Docs: gform_noconflict_scripts

Examples

Register a custom script with Gravity Forms

This example shows how to register a custom script with Gravity Forms to ensure it gets enqueued when running on no-conflict mode.

add_action('admin_enqueue_scripts', 'enqueue_form_editor_script');

function enqueue_form_editor_script() {
    if (RGForms::is_gravity_page()) {
        // Enqueuing my script on Gravity Form pages
        wp_enqueue_script('my_script', plugins_url('my-script.js', 'my-plugin'));
    }
}

add_filter('gform_noconflict_scripts', 'register_script');

function register_script($scripts) {
    // Registering my script with Gravity Forms so that it gets enqueued when running on no-conflict mode
    $scripts[] = 'my_script';
    return $scripts;
}

Placement: This code should be placed in the functions.php file of your active theme.

Source Code: This filter is located in GFForms::no_conflict_mode() in gravityforms.php.