Same name and namespace in other branches
  1. 4.6.x developer/hooks/core.php \hook_settings()

Declare administrative settings for a module.

This hook provides an administrative interface for controlling various settings for this module. A menu item for the module under "administration >> settings" will appear in the administrative menu when this hook is implemented.

Return value

An array containing form items to place on the module settings page.

The form items defined on the settings page will be saved with variable_set(), and can be later retrieved with variable_get(). If you need to store more complicated data (for example, in a separate table), define your own administration page and link to it using hook_menu().

NOTE: if you are using 'checkboxes' or a multiple select, you may wish to include the array_filter element within your form: $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);

Related topics

16 functions implement hook_settings()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_settings in modules/aggregator.module
Implementation of hook_settings().
blogapi_settings in modules/blogapi.module
contact_admin_settings in modules/contact.module
Settings tab. Using a form rather than hook_settings().
drupal_settings in modules/drupal.module
Implementation of hook_settings().
image_gd_check_settings in includes/image.inc
Verify GD2 settings (that the right version is actually installed).

... See full list

File

developer/hooks/core.php, line 921
These are the hooks that are invoked by the Drupal core.

Code

function hook_settings() {
  $form['example_a'] = array(
    '#type' => 'textfield',
    '#title' => t('Setting A'),
    '#default_value' => variable_get('example_a', 'Default setting'),
    '#size' => 20,
    '#maxlength' => 255,
    '#description' => t('A description of this setting.'),
  );
  $form['example_b'] = array(
    '#type' => 'checkbox',
    '#title' => t('Setting B'),
    '#default_value' => variable_get('example_b', 0),
    '#description' => t('A description of this setting.'),
  );
  return $form;
}