4.6.x system.module system_settings_form($form)
4.7.x system.module system_settings_form($form_id, $form)
5.x system.module system_settings_form($form)
6.x system.module system_settings_form($form)
7.x system.module system_settings_form($form)

Sets up a form to save information automatically.

This function adds a submit handler and a submit button to a form array. The submit function saves all the data in the form, using variable_set(), to variables named the same as the keys in the form array. Note that this means you should normally prefix your form array keys with your module name, so that they are unique when passed into variable_set().

If you need to manipulate the data in a custom manner, you can either put your own submission handler in the form array before calling this function, or just use your own submission handler instead of calling this function.


$form: An associative array containing the structure of the form.

Return value

The form structure.

See also


Related topics

22 calls to system_settings_form()
book_admin_settings in modules/book/book.admin.inc
Form constructor for the book settings form.
forum_admin_settings in modules/forum/forum.admin.inc
Form constructor for the forum settings page.
locale_language_providers_session_form in modules/locale/locale.admin.inc
The URL language provider configuration form.
locale_language_providers_url_form in modules/locale/locale.admin.inc
The URL language provider configuration form.
menu_configure in modules/menu/menu.admin.inc
Menu callback; Build the form presenting menu configuration options.

... See full list


modules/system/system.module, line 2799
Configuration system that lets administrators modify the workings of the site.


function system_settings_form($form) {
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  if (!empty($_POST) && form_get_errors()) {
    drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
  $form['#submit'][] = 'system_settings_form_submit';

  // By default, render the form using theme_system_settings_form().
  if (!isset($form['#theme'])) {
    $form['#theme'] = 'system_settings_form';
  return $form;


Sibiraj PR’s picture

SebCorbin’s picture

If you need to save filtered array values, like this:

$form['mymodule_node_types'] = array(
  '#type' => 'checkboxes',
  '#title' => t("Node types enabled for my module"),
  '#options' => node_type_get_names(),
  '#default_value' => variable_get('mymodule_node_types'),

You can automatically filter array values simply by adding this form component:

$form['array_filter'] = array(
  '#type' => 'value',
  '#value' => TRUE,
stefgosselin’s picture

Ok... but what does this do?

vomitHatSteve’s picture

It sets up a submit handler to automatically save all form values into the variable table.


$form['my_value'] = array(
  '#type' => 'textfield',
  '#title' => t('My Field'),
  '#default' => variable_get('my_value', 'value'),
return system_settings_form($form);

Will result in a form with one textfield and a submit button. Hitting the submit button will save the value of the textfield in the variable table as 'my_value' so you can access it later with variable_get('my_value', 'default value')

Nikdhil Mdohfan’s picture

there is no #default in FAPI

suvzz’s picture

jedihe’s picture

For details about 'array_filter', have a look at https://api.drupal.org/api/drupal/modules%21system%21system.module/funct...

NancyDru’s picture

If you use the "text_format" field type, it will save an array with two elements, 'value' and 'format'.