gform_editor_field_settings

Description

The gform_editor_field_settings filter allows the editor settings that are used for the current field, including those inherited from the inputType, to be overridden.

Usage

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

gform.addFilter( 'gform_editor_field_settings', function( settingsArray, field ) {
    // do stuff

    return settingsArray;
} );

Parameters

  • settingsArray array

    The current settings for the field. See Field Settings for available settings.

    [
      ".conditional_logic_field_setting",
      ".prepopulate_field_setting",
      ".error_message_setting",
      ".label_setting",
      ".label_placement_setting",
      ".admin_label_setting",
      ".size_setting",
      ".input_mask_setting",
      ".maxlen_setting",
      ".password_field_setting",
      ".rules_setting",
      ".visibility_setting",
      ".duplicate_setting",
      ".default_value_setting",
      ".placeholder_setting",
      ".description_setting",
      ".css_class_setting",
      ".autocomplete_setting"
    ]
    

  • field Javascript Object | Field Object

    The field being modified.

Examples

1. Remove a setting

This example shows how a setting can be removed from a specific field type.

gform.addFilter( 'gform_editor_field_settings', function( settings, field ) {
    if ( field.type !== 'quiz' ) {
        return settings;
    }

    // Find the index of the choices setting
    var i = settings.indexOf( '.choices_setting' );

    // Doesn't exist; bail.
    if ( i === -1 ) {
        return settings;
    }

    // Remove the choices_setting value.
    settings.splice( i, 1 );

    return settings;
} );

Placement

This code should be placed in a JavaScript file included in the admin by your plugin.

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in getAllFieldSettings() in form_editor.js.