Skip navigation
Help

hook_filter_FILTER_settings

7 filter.api.php hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $defaults, $filters)

Settings callback for hook_filter_info().

Note: This is not really a hook. The function name is manually specified via 'settings callback' in hook_filter_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 filter settings, for filters that need settings on a per-text-format basis. 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 filter's behavior depends on an extensive list and/or external data (e.g. a list of smileys, a list of glossary terms), then the filter 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.

$filter: The filter object containing the current settings for the given format, in $filter->settings.

$format: The format object being configured.

$defaults: The default settings for the filter, as defined in 'default settings' in hook_filter_info(). These should be combined with $filter->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

drupal/modules/filter/filter.api.php, line 162
Hooks provided by the Filter module.

Code

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

  $elements = array();
  $elements['nofollow'] = array(
    '#type' => 'checkbox', 
    '#title' => t('Add rel="nofollow" to all links'), 
    '#default_value' => $filter->settings['nofollow'],
  );
  return $elements;
}