Commit 4f50bc1c authored by webchick's avatar webchick

Issue #1599554 by sun, dww, effulgentsia: Tutorial/guidelines for how to...

Issue #1599554 by sun, dww, effulgentsia: Tutorial/guidelines for how to convert variables into configuration.
parent 87dc82a4
......@@ -721,6 +721,9 @@ function drupal_form_submit($form_id, &$form_state) {
function drupal_retrieve_form($form_id, &$form_state) {
$forms = &drupal_static(__FUNCTION__);
// Record the $form_id.
$form_state['build_info']['form_id'] = $form_id;
// Record the filepath of the include file containing the original form, so
// the form builder callbacks can be loaded when the form is being rebuilt
// from cache on a different path (such as 'system/ajax'). See
......
......@@ -1735,12 +1735,6 @@ function system_performance_settings($form, &$form_state) {
'#disabled' => $disabled,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['#submit'][] = 'drupal_clear_css_cache';
$form['#submit'][] = 'drupal_clear_js_cache';
// This form allows page compression settings to be changed, which can
......@@ -1748,7 +1742,7 @@ function system_performance_settings($form, &$form_state) {
$form['#submit'][] = 'system_clear_page_cache_submit';
$form['#submit'][] = 'system_performance_settings_submit';
return $form;
return system_config_form($form, $form_state);
}
/**
......
......@@ -3025,6 +3025,63 @@ function system_settings_form_submit($form, &$form_state) {
drupal_set_message(t('The configuration options have been saved.'));
}
/**
* Adds default behavior to a configuration form.
*
* This includes a consistent 'Save configuration' button, theme definition,
* and submit handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param array $form_state
* Reference to an associative array containing state of the form.
*
* @return array
* The form structure.
*
* @see system_config_form_submit()
* @ingroup forms
*
* @todo Replace this temporary helper with a more sophisticated solution:
* http://drupal.org/node/1324618.
*/
function system_config_form($form, &$form_state) {
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
// Add system_config_form_submit() to output a consistent confirmation
// message. Since this prevents drupal_prepare_form() from adding the form's
// primary submit handler, do that first, using the same logic.
if (!isset($form['#submit'])) {
$form['#submit'] = array();
if (function_exists($form_state['build_info']['form_id'] . '_submit')) {
$form['#submit'][] = $form_state['build_info']['form_id'] . '_submit';
}
elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) {
$form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit';
}
}
$form['#submit'][] = 'system_config_form_submit';
// By default, render the form using theme_system_settings_form().
if (!isset($form['#theme'])) {
$form['#theme'] = 'system_settings_form';
}
return $form;
}
/**
* Form submission handler for system_config_form().
*
* @see system_config_form()
*/
function system_config_form_submit($form, &$form_state) {
drupal_set_message(t('The configuration options have been saved.'));
}
/**
* Helper function to sort requirements.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment