bookmark_bordergform_form_settings

Description

Add new or modify existing form settings that display on the Form Settings screen.

Usage

Apply to all forms:

add_filter( 'gform_form_settings', 'my_custom_function', 10, 2 );

Parameters

  • $settings array

    An array of settings for the Form Settings UI. Each setting contains the HTML which will be displayed for that setting. The array keys are the group titles so could be translated.

    array(
    			'Form Basics'       => array(
    					'form_title'       => '',
    					'form_description' => '',
    			),
    			'Form Layout'       => array(
    					'form_label_placement'       => '',
    					'form_description_placement' => '',
    					'form_sub_label_placement'   => '',
    					'css_class_name'             => '',
    			),
    			'Form Button'       => array(
    					'form_button_type'        => '',
    					'form_button_text'        => '',
    					'form_button_image_path'  => '',
    					'form_button_conditional' => '',
    			),
    			'Save and Continue' => array(
    					'save_enabled'     => '',
    					'save_warning'     => '',
    					'save_button_text' => '',
    			),
    			'Restrictions'      => array(
    					'limit_entries'            => '',
    					'number_of_entries'        => '',
    					'entry_limit_message'      => '',
    					'schedule_form'            => '',
    					'schedule_start'           => '',
    					'schedule_end'             => '',
    					'schedule_pending_message' => '',
    					'schedule_message'         => '',
    					'requires_login'           => '',
    					'requires_login_message'   => '',
    			),
    			'Form Options'      => array(
    					'honey_pot'        => '',
    					'enable_animation' => '',
    			),
    	);

    To access the array you can translate the key like so:

    $settings[ __( 'Form Basics', 'gravityforms' ) ]

  • $form

    The current form object being displayed.

Examples

This example demonstrates how you can add a custom form setting to the Form Settings page. As part of this process, it also demonstrates how to save your custom setting via the gform_pre_form_settings_save filter. You may add your custom setting to a specific section on the Form Settings page by using the section header. The example below displays the custom setting in the section titled “Form Button” as the last item.

add_filter( 'gform_form_settings', 'my_custom_form_setting', 10, 2 );
function my_custom_form_setting( $settings, $form ) {
    $settings[ __( 'Form Button', 'gravityforms' ) ]['my_custom_setting'] = '
        <tr>
            <th><label for="my_custom_setting">My Custom Label</label></th>
            <td><input value="' . rgar($form, 'my_custom_setting') . '" name="my_custom_setting"></td>
        </tr>';

    return $settings;
}

// save your custom form setting
add_filter( 'gform_pre_form_settings_save', 'save_my_custom_form_setting' );
function save_my_custom_form_setting($form) {
    $form['my_custom_setting'] = rgpost( 'my_custom_setting' );
    return $form;
}

This example shows you how to update your code from the deprecated gform_properties_settings or gform_advanced_settings hook.

add_filter( 'gform_form_settings', 'add_form_setting', 10, 2 );
function my_custom_form_setting( $settings, $form ) {
    //add
     $settings[ __( 'Form Basics', 'gravityforms' ) ]['my_custom_setting']= '
        <tr>
            <th><label for="my_custom_setting">My Custom Label</label></th>
            <td><input value="' . rgar($form, 'my_custom_setting') . '" name="my_custom_setting"></td>
        </tr>';

    return $settings;
}
// save your custom form setting
add_filter( 'gform_pre_form_settings_save', 'save_my_custom_form_setting' );
function save_my_custom_form_setting( $form ) {
    $form['my_custom_setting'] = rgpost( 'my_custom_setting' );
    return $form;
}

Source Code

This filter is located in the following methods:

  • GFFormDetail::forms_page() in form_detail.php
  • GFFormSettings::form_settings_ui() in form_settings.php