1 filter.api.php hook_editor_EDITOR_settings($form, &$form_state, $format, $defaults, $filters)

Settings callback for hook_editor_info().

Note: This is not really a hook. The function name is manually specified via 'settings callback' in hook_editor_info(), with this recommended callback name pattern. It is called from filter_admin_format_form().

This callback function is used to provide a settings form for editor settings. This function should return the form elements for the settings; the Filter module will take care of saving the settings in the database.

If the editor's behavior depends on an extensive list and/or external data, then the editor module can choose to provide a separate, global configuration page rather than per-text-format settings. In that case, the settings callback function should provide a link to the separate settings page.

Parameters

$form: The prepopulated form array of the filter administration form.

$form_state: The state of the (entire) configuration form.

$format: The format object being configured.

$defaults: The default settings for the editor, as defined in 'default settings' in hook_editor_info(). These should be combined with $editor->settings to define the form element defaults.

$filters: The complete list of filter objects that are enabled for the given format.

Return value

An array of form elements defining settings for the filter. Array keys: should match the array keys in $filter->settings and $defaults.

File

core/modules/filter/filter.api.php, line 524
Hooks provided by the Filter module.

Code

function hook_editor_EDITOR_settings($form, &$form_state, $format, $defaults, $filters) {
  $format->settings += $defaults;

  $elements = array();
  $elements['enable_toolbar'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable toolbar'),
    '#default_value' => $format->settings['enable_toolbar'],
  );
  $elements['buttons'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enabled buttons'),
    '#options' => array(
      'bold' => t('Bold'),
      'italic' => t('Italic'),
      'underline' => t('Underline'),
      'link' => t('Link'),
      'image' => t('Image'),
    ),
    '#default_value' => $format->settings['buttons'],
  );
  $elements['resizeable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Resizeable'),
    '#default_value' => $format->settings['resizeable'],
  );
  return $elements;
}