Community Documentation

system_settings_form

5 system.module system_settings_form($form)
6 system.module system_settings_form($form)
7 system.module system_settings_form($form)
8 system.module system_settings_form($form)

Add default buttons to a form and set its prefix.

Parameters

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

Return value

The form structure.

See also

system_settings_form_submit()

Related topics

▾ 27 functions call 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.
filter_admin_configure in modules/filter/filter.admin.inc
Build a form to change the settings for a format's filters.
forum_admin_settings in modules/forum/forum.admin.inc
Form builder for the forum settings page.
menu_configure in modules/menu/menu.admin.inc
Menu callback; Build the form presenting menu configuration options.
node_configure in modules/node/node.admin.inc
Menu callback; presents general node configuration options.
search_admin_settings in modules/search/search.admin.inc
Menu callback; displays the search module settings page.
statistics_access_logging_settings in modules/statistics/statistics.admin.inc
Form builder; Configure access logging.
syslog_admin_settings in modules/syslog/syslog.module
system_admin_theme_settings in modules/system/system.admin.inc
Form builder; This function allows selection of the theme to show in administration sections.
system_clean_url_settings in modules/system/system.admin.inc
Form builder; Configure Clean URL settings.
system_date_time_settings in modules/system/system.admin.inc
Form builder; Configure the site date and time settings.
system_error_reporting_settings in modules/system/system.admin.inc
Form builder; Configure error reporting settings.
system_file_system_settings in modules/system/system.admin.inc
Form builder; Configure the site file handling.
system_image_toolkit_settings in modules/system/system.admin.inc
Form builder; Configure site image toolkit usage.
system_performance_settings in modules/system/system.admin.inc
Form builder; Configure site performance settings.
system_rss_feeds_settings in modules/system/system.admin.inc
Form builder; Configure how the site handles RSS feeds.
system_site_information_settings in modules/system/system.admin.inc
Form builder; The general site information form.
system_site_maintenance_settings in modules/system/system.admin.inc
Form builder; Configure the site's maintenance status.
system_theme_settings in modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.
throttle_admin_settings in modules/throttle/throttle.admin.inc
Form builder; Configure the throttle system.
update_settings in modules/update/update.settings.inc
Form builder for the update settings tab.
upload_admin_settings in modules/upload/upload.admin.inc
Menu callback for the upload settings form.
user_admin_settings in modules/user/user.admin.inc
Form builder; Configure user settings for this site.

File

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

Code

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

Comments

One little bug with this

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

Your whole form should really

Your whole form should really not be in a fieldset!

Sometimes there are good

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.

Yeah. - and sometimes you just want to remove the Reset button

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

fieldset issue SOLVED

ivanjaros,
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.

Login or register to post comments