Why isn't this Config API Code saving options? I can see the form, using the Config API, and submit it. However, it doesn't save the changes. Here is my code:    

    &lt;?php

namespace Drupal\my_config\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;


class MyConfigForm extends ConfigFormBase {


  public function getFormId () {
    return 'my_config_settings';
  }

  protected function getEditableConfigNames() {
    return [
      'my_config.config',
    ];
  }


  public function buildForm (array $form, FormStateInterface $form_state) {


    $form['author_config'] = array(
      '#type' =&gt; 'textfield',
      '#default_value' =&gt; \Drupal::config('config.factory')-&gt;get('author_config'),
      '#title' =&gt; 'Author of Config',
      '#required' =&gt; TRUE,
    );
    $form['language'] = array(
      '#type' =&gt; 'radios',
      '#title' =&gt; 'Language',
      '#options' =&gt; array(
        'EN' =&gt; t('English'),
        'SP' =&gt; t('Spanish'),
        'FR' =&gt; t('French'),
        'DE' =&gt; t('German'),
      ),
    );
    $form['drink'] = array (
      '#type' =&gt; 'select',
      '#title' =&gt; 'Select your drink',
      '#options' =&gt; array(
        'RB' =&gt; t('Root Beer'),
        'SD' =&gt; t('Sunny Delight'),
        'WR' =&gt; t('Water'),
        'OJ' =&gt; t('Orange Juice'),
      ),
    );
    return parent::buildForm($form, $form_state);
  }


  public function submitForm (array &amp;$form, FormStateInterface $form_state) {

    \Drupal::service('config.factory')-&gt;getEditable('my_config.config')-&gt;set('author_config', $form_state-&gt;getValue('author_config'))
     -&gt;set('language', $form_state-&gt;getValue('language'))
         -&gt;set('drink', $form_state-&gt;getValue('drink'))-&gt;save();
    parent::submitForm($form, $form_state);
  }

}


This is my routing file:

my_config.settings:
  path: '/my-config/config'
  defaults:
    _form: '\Drupal\my_config\Form\MyConfigForm'
    _title: 'Configuration Form'
  requirements:
    _permission: 'administer site configuration'
This is wrong:

'#default_value' =&gt; \Drupal::config('config.factory')-&gt;get('author_config'),


It should be:

'#default_value' =&gt; \Drupal::config('my_config.config')-&gt;get('author_config'),


This is the entire form:

$form['author_config'] = array(
  '#type' =&gt; 'textfield',
  '#default_value' =&gt; \Drupal::config('my_config.config')-&gt;get('author_config'),
  '#title' =&gt; 'Author of Config',
  '#required' =&gt; TRUE,
);
$form['language'] = array(
  '#type' =&gt; 'radios',
  '#title' =&gt; 'Language',
  '#default_value' =&gt; \Drupal::config('my_config.config')-&gt;get('language'),
  '#options' =&gt; array(
    'EN' =&gt; t('English'),
    'SP' =&gt; t('Spanish'),
    'FR' =&gt; t('French'),
    'DE' =&gt; t('German'),
  ),
);
$form['drink'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; 'Select your drink',
  '#default_value' =&gt; \Drupal::config('my_config.config')-&gt;get('drink'),
  '#options' =&gt; array(
    'RB' =&gt; t('Root Beer'),
    'SD' =&gt; t('Sunny Delight'),
    'WR' =&gt; t('Water'),
    'OJ' =&gt; t('Orange Juice'),
  ),
);


Probably using $this->config the problem will be solved too