hook_settings

  1. drupal
    1. 4.7
Versions
4.7 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

Code

developer/hooks/core.php, line 922

<?php
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;
}
?>