diff -u b/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc --- b/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1480,7 +1480,7 @@ */ function system_site_information_settings($form, &$form_state) { $form['#config'] = config('system.site'); - $site_mail = $site_config->get('mail'); + $site_mail = $form['#config']->get('mail'); if (empty($site_mail)) { $site_mail = ini_get('sendmail_from'); } @@ -1517,8 +1517,7 @@ $form['front_page']['site_frontpage'] = array( '#type' => 'textfield', '#title' => t('Default front page'), - '#load' => 'config', - '#config_key' => 'page.front' != 'user' ? drupal_get_path_alias($site_config->get('page.front')) : '', + '#default_value' => ($form['#config']->get('page.front') != 'user' ? drupal_get_path_alias($form['#config']->get('page.front')) : ''), '#size' => 40, '#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default content feed.'), '#field_prefix' => url(NULL, array('absolute' => TRUE)), @@ -1586,6 +1585,16 @@ } /** + * Form submission handler for system_site_information_settings(). + */ +function system_site_information_settings_submit($form, &$form_state) { + config('system.site') + ->set('mail', $form_state['values']['site_mail']) + ->set('page.front', $form_state['values']['site_frontpage']) + ->save(); +} + +/** * Form builder; Cron form. * * @ingroup forms diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3235,6 +3235,13 @@ * 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'), + ); + + // Autoload default values for managed elements. $config = isset($form['#config']) ? $form['#config'] : NULL; $form_state['callbacks']['load']['config'] = function ($element) use ($config) { if (isset($element['#config'])) { @@ -3243,15 +3250,10 @@ return $config->get($element['#config_key']); }; - $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. + // Add system_config_form_submit() as the first submit handler to autosave + // submitted values of managed elements. 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')) { @@ -3261,7 +3263,7 @@ $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit'; } } - $form['#submit'][] = 'system_config_form_submit'; + array_unshift($form['#submit'], 'system_config_form_submit'); // By default, render the form using theme_system_settings_form(). if (!isset($form['#theme'])) { @@ -3276,13 +3278,15 @@ * @see system_config_form() */ function system_config_form_submit($form, &$form_state) { - foreach ($form_state['loadables']['config'] as $array_parents) { - $element = NestedArray::getValue($form, $array_parents); - $value = ($element['#type'] == 'checkboxes') ? array_keys(array_filter($element['#value'])) : $element['#value']; - $config = isset($element['#config']) ? $element['#config'] : $form['#config']; - $config->set($element['#config_key'], $value); + if (isset($form_state['loadables']['config'])) { + foreach ($form_state['loadables']['config'] as $array_parents) { + $element = NestedArray::getValue($form, $array_parents); + $value = ($element['#type'] == 'checkboxes') ? array_keys(array_filter($element['#value'])) : $element['#value']; + $config = isset($element['#config']) ? $element['#config'] : $form['#config']; + $config->set($element['#config_key'], $value); + $config->save(); + } } - $config->save(); drupal_set_message(t('The configuration options have been saved.')); }