diff --git a/core/includes/form.inc b/core/includes/form.inc index c94bc62..571a439 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -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 diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 819df67..428772d 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1735,20 +1735,13 @@ 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 // invalidate the page cache, so it needs to be cleared on form submit. $form['#submit'][] = 'system_clear_page_cache_submit'; - $form['#submit'][] = 'system_performance_settings_submit'; - return $form; + return system_config_form($form, $form_state); } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index d43455e..c10d011 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3026,6 +3026,46 @@ function system_settings_form_submit($form, &$form_state) { } /** + * Adds default buttons, theme definition, and submit handler to a configuration form. + * + * @param array $form + * An associative array containing the structure of the form. + * + * @return array + * The form structure. + * + * @see system_config_form_submit() + * @ingroup forms + * + * @todo D8: Replace this temporary helper with a more sophisticated solution. + */ +function system_config_form($form, &$form_state) { + $form['actions']['#type'] = 'actions'; + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save configuration'), + ); + // Add the form's primary submit handler for saving configuration values and + // append system_config_form_submit() to output a consistent confirmation + // message. + $form['#submit'][] = $form_state['build_info']['form_id'] . '_submit'; + $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; +} + +/** + * Form submission handler for 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. */ function _system_sort_requirements($a, $b) {