Custom save message for site information form Folks,
I need to alter the site information form. I used api_form_system_site_information_settings_alter hook to do so. After submitting I need to print a custom message. I used one submission handler, but the data not saved. My .module file is given below.

use Drupal\Core\Form\FormStateInterface;

function api_key_form_system_site_information_settings_alter(&amp;$form, 
 FormStateInterface $form_state, $form_id) {
 if($form_id != 'system_site_information_settings') {
    return;
}
$site_api = \Drupal::config('api_key.settings')-&gt;get('siteapikey');

$form['api_settings'] = array(
    '#type' =&gt; 'details',
    '#title' =&gt;t('Site API settings'),
    '#open' =&gt; true
);

$form['api_settings']['siteapikey'] = [
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('API Key'),
    '#default_value' =&gt; $site_api,
    '#description' =&gt; t('Enter the API key for making the site 
        protected on API calls'),
    '#maxlength' =&gt; 32,
    '#required' =&gt; true,
    '#placeholder'=&gt; t('No API key yet')
];

$value = !empty($site_api)? t('Update Configuration'): t('Save Configuration');
$form['api_settings']['actions']['#type'] = 'actions';
$form['api_settings']['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; $value,
    '#button_type' =&gt; 'primary',
];
$form['actions']['submit']['#submit'][] = 'api_key_form_submit';
return $form;
 }

function api_key_form_submit(array $form, FormStateInterface $form_state) {

$site_api = \Drupal::config('api_key.settings')-&gt;get('siteapikey');
//Reads the new value form the form instance.
$new_value = $form_state-&gt;getValue('siteapikey');
//Changes the success message based on the condtions.
if(!empty($site_api)) {
        //Sets update message.
    $message = t('Site API key is changed from @old_value to 
        @new_value', [
            '@old_value'=&gt; $site_api, 
            '@new_value'=&gt; $new_value
        ]);
} else {
        //Sets success message.
    $message = t('@new_value is set as site API key.',
        ['@new_value'=&gt;$new_value]);
}

//Prints the message.
drupal_set_message($message,$type='status', $repeat=true);
}
It seems you have success with displaying the message but not with saving the value? For this you need to load the editable version of the config, set the value and save:

function api_key_form_submit($form, FormStateInterface $form_state) {
  $config = \Drupal::service('config.factory')-&gt;getEditable('api_key.settings');
  $config-&gt;set('siteapikey', $form_state-&gt;getValue('siteapikey'));
  $config-&gt;save();
}


By the way it's also a good idea to get the value from the editable version because the config might be overridden and you want to fill the form with the original value:

$site_api = \Drupal::service('config.factory')-&gt;getEditable('api_key.settings')-&gt;get('siteapikey');