How to save dynamic select list value into config table in Drupal 8? I wanted to show list of fields per content type in admin config form. After saving the form, selected list value should get save into config table. 

public function buildForm(array $form, FormStateInterface $form_state) {
  foreach (node_type_get_types() as $content_type) {
    $entity_type_id = 'node';
    $fields = \Drupal::entityManager()-&gt;getFieldDefinitions('node', $content_type-&gt;get('type'));
    if ($fields) {
      $options = array();
      foreach ($fields as $field_name =&gt; $field_definition) {
        if (!empty($field_definition-&gt;getTargetBundle())) {
          $options[$field_name] = $field_definition-&gt;getLabel();
        }
      }
      $form['test']['test_' . $content_type-&gt;get('type') . '_field'] = array(
        '#type' =&gt; 'select',
        '#title' =&gt; $content_type-&gt;get('name'),
        '#options' =&gt; array_merge(array('0' =&gt; t('Auto')), $options),
        '#default_value' =&gt; $config-&gt;get('test_' . $content_type-&gt;get('type') . '_field') ? $config-&gt;get('test_' . $content_type-&gt;get('type') . '_field') : '',
      );
    }
  }
}


Here is submit handler 

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

foreach (node_type_get_types() as $content_type) {
  $this-&gt;config('test.settings')
  -&gt;set('test_' . $content_type-&gt;get('type') . '_field', $form_state-&gt;getValue('test', 'test_' . $content_type-&gt;get('type') . '_field'))
  -&gt;save();
}     
parent::submitForm($form, $form_state); }


After saving admin form, test_article_field and test_page_field  is getting saved instead of selected field.

Any help would be appreciated?
There is some problem in the submit handler.

Replace

$this-&gt;config('test.settings')
 -&gt;set('test_' . $content_type-&gt;get('type') . '_field', $form_state-&gt;getValue('test', 'test_' . $content_type-&gt;get('type') . '_field'))
 -&gt;save();


line with

$this-&gt;config('test.settings')
  -&gt;set('test_' . $content_type-&gt;get('type') . '_field', $form_state-&gt;getValues('test_' . $content_type-&gt;get('type') . '_field'))
  -&gt;save();


Hope that this helps you.