gform_rich_text_editor_options

Description

The “gform_rich_text_editor_options” filter in Gravity Forms allows the rich text editor options to be modified. A specific FORMID or FORMID + FIELDID may also be used with the hook.

Usage

Applies to all forms:

add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

Targets a specific form:

add_filter( 'gform_rich_text_editor_options_3', 'my_function', 10, 4 );

Targets a specific field for a specific form:

add_filter( 'gform_rich_text_editor_options_3_6', 'my_function', 10, 4 );

Parameters

  • $editor_settings array

    Array of buttons to include within the TinyMCE editor inside Gravity Forms.

    Defaults to the following:

      array(
          'textarea_name' => 'input_' . $id,
          'wpautop'       => true,
          'editor_class'  => $class,
          'textarea_rows' => 10,
          'tabindex'      => $tabindex,
          'media_buttons' => false,
          'quicktags'     => false,
          'tinymce'       => array( 'init_instance_callback' => 'function...' ),
      );
      

  • $field_object object

    The full field object returned.

  • $form array

    The form that the filter is being run on.

  • $entry array

    The entry, if available.

Examples

1. Set a custom height value

function my_function( $editor_settings, $field_object, $form, $entry ) {
    $editor_settings['editor_height'] = 400;
    return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

2. Enable the Add Media button

This will add the Add Media button before the toolbar just like WP does in Post/Page editor. The user must be logged in to see the button; this is a WordPress requirement not a Gravity Forms limitation.

function show_media_button( $editor_settings, $field_object, $form, $entry ) {
    $editor_settings['media_buttons'] = true;
    return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'show_media_button', 10, 4 );

Source Code

This filter is located in class-gf-field-textarea.php.