Using Gravity Forms ‘gform_noconflict_styles’ PHP filter

The gform_noconflict_styles filter allows you to register your CSS file with Gravity Forms, ensuring it gets enqueued in the form editor page when no-conflict mode is enabled.

Usage

add_filter('gform_noconflict_styles', 'register_style');

Parameters

  • $styles (array): An array of style handles to be filtered. Add styles to this array to register them (e.g. $styles[] = 'my-style-handle';).

More information

See Gravity Forms Docs: gform_noconflict_styles

Examples

Register a custom style with Gravity Forms

This example registers a custom style with Gravity Forms.

add_action('admin_head', 'enqueue_form_editor_style');

function enqueue_form_editor_style() {
    if (RGForms::is_gravity_page()) {
        // Enqueueing my style on gravity form pages
        wp_enqueue_style('my_style', plugins_url('my-style.css', 'my-plugin'));
    }
}

add_filter('gform_noconflict_styles', 'register_style');

function register_style($styles) {
    // Registering my style with Gravity Forms so that it gets enqueued when running on no-conflict mode
    $styles[] = 'my_style';
    return $styles;
}

Place this code in the functions.php file of your active theme.

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