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)

Add default buttons to a form and set its prefix.


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

Return value

The form structure.

See also


Related topics

27 calls to system_settings_form()
aggregator_admin_settings in modules/aggregator/aggregator.admin.inc
Form builder; Configure the aggregator system.
blogapi_admin_settings in modules/blogapi/blogapi.module
book_admin_settings in modules/book/book.admin.inc
Builds and returns the book settings form.
contact_admin_settings in modules/contact/contact.admin.inc
dblog_admin_settings in modules/dblog/dblog.admin.inc
dblog module settings form.

... See full list


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


function system_settings_form($form) {
  $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
  $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));

  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';
  $form['#theme'] = 'system_settings_form';
  return $form;


ivanjaros’s picture

One little bug with this function is that if you have your whole form in fieldset the buttons wont be in it.

joachim’s picture

Your whole form should really not be in a fieldset!

Drave Robber’s picture

Sometimes there are good reasons to put the whole form in a fieldset, e.g., when placing a settings form (collapsed or not) at the top of a page that contains other content.

The method to move buttons into the fieldset is fairly simple – just don't return system_settings_form() immediately but manipulate it a bit:

  // ...definition of the form as usual...
  $form = system_settings_form($form);
  $form['fieldset']['buttons'] = $form['buttons'];
  unset ($form['buttons']);
  return $form;

Replace 'fieldset' with the name of your fieldset, of course.

rosell.dk’s picture

To just remove the reset button, do like this:
unset ($form['buttons']['reset']);

Nikki Aiuto’s picture

I had the same problem as you and spent too much time trying to figure this out, but I finally did. According to the Form API QuickStart guide:

An important thing to note: notice that $form['access'] has a '#tree' => TRUE attribute. this setting retains the full tree structure for all elements under it when it is passed to $form_state['values']. you must explicitly declare this anywhere you wish to retain an array's full hierarchy when it is passed.

My fieldset had #tree set to TRUE. When I removed that, the field values were flattened and placed in the 'values' array of form_state and then system_settings_form_submit was able to find them and process them.

pesoman’s picture

Hello I am new in module development how to specify the type to "select" (drop-down-list) ?