| 7 system.module | system_settings_form($form) |
| 4.6 system.module | system_settings_form($form) |
| 4.7 system.module | system_settings_form( |
| 5 system.module | system_settings_form($form) |
| 6 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
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.
File
- modules/
system/ system.module, line 1107 - Configuration system that lets administrators modify the workings of the site.
Code
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
PermalinkOne 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
PermalinkYour whole form should really not be in a fieldset!
Sometimes there are good
PermalinkSometimes 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
PermalinkTo just remove the reset button, do like this:
unset ($form['buttons']['reset']);
fieldset issue SOLVED
Permalinkivanjaros,
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.
form #type
PermalinkHello I am new in module development how to specify the type to "select" (drop-down-list) ?