gform_editor_sidebar_panels

Description

The gform_editor_sidebar_panels filter enables custom panels to be registered for display in the form editor sidebar. Use the gform_editor_sidebar_panel_content action hook to echo the panel content.

Usage

The filter which would run for all forms would be used like so:

1
add_filter( 'gform_editor_sidebar_panels', 'your_function_name', 10, 2 );

You can also target a specific form by adding the form id after the hook name.

1
add_filter( 'gform_editor_sidebar_panels_6', 'your_function_name', 10, 2 );

Parameters

ParameterTypeDescription
$panelsarrayAn array of custom sidebar panels.
$formForm ObjectThe form currently being edited.

Examples

1. Add a new panel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
add_filter( 'gform_editor_sidebar_panels', function ( $panels, $form ) {
    $panels[] = array(
        // Define the unique ID for your panel.
        'id'           => 'my_custom_panel_1',
        // Define the title to be displayed on the toggle button for your panel.
        'title'        => 'My Custom Panel',
        // Define an array of classes to be added to the toggle button for your panel.
        'nav_classes'  => array( 'my_nav_class_1', 'my_nav_class_2' ),
        // Define an array of classes to be added to the body of your panel.
        'body_classes' => array( 'my_body_class_1' ),
    );
 
    return $panels;
}, 10, 2 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in GFFormDetail::forms_page() in form_detail.php