How to save a checkbox config_object in the schema files? We have a custom module with the following files. It is mainly used to store a list of content types that this configuration applies to. When saving the configuration, we get the following code. 

How do we properly set the mymodule.schema.yml file to save the checkboxes?

Error Message. We also get the error message if we select Basic Page from the configuration. 


  The website encountered an unexpected error. Please try again
  later.InvalidArgumentException:
  The configuration property mymodule_enabled_content_types.article
  doesn&#039;t exist. in Drupal\Core\Config\Schema\ArrayElement-&gt;get()
  (line 76 of core\lib\Drupal\Core\Config\Schema\ArrayElement.php).
  Drupal\Core\Config\StorableConfigBase-&gt;castValue(&#039;mymodule_enabled_content_types.article
  &#039;, &#039;article &#039;) (Line: 211)


mymodule/config/schema/mymodule.schema.yml

mymodule.settings:
  type: config_object
  label: 'My Module settings'
  mapping: 
    mymodule_enabled_content_types:
      type: string
      label: 'Enabled Content types'


mymodule/config/install/mymodule.settings.yml

mymodule_enabled_content_types: ''


mymoduleForm.php

...
public function buildForm(array $form, FormStateInterface $form_state) {
  $config-&gt;$this-&gt;config('mymodule.settings');
  // Get all Content Types.
  $types = \Drupal::entityTypeManager()
    -&gt;getStorage('node_type')
    -&gt;loadMultiple();

  foreach($types as $type) {
    $content_types[$type-&gt;id()] = $type-&gt;label();
  }
  $form['mymodule_enabled_content_types'] = [
    '#type' =&gt; 'checkboxes',
    '#title' =&gt; $this-&gt;t('Enabled Content Types'),
    '#description' =&gt; $this-&gt;t('Define what content types will be enabled.'),
    '#default_value' =&gt; $config-&gt;get('mymodule_custom_variable'),
    '#options' =&gt; $content_types,
  ];
}

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    // Retrieve the configuration
    $this-&gt;configFactory-&gt;getEditable('mymodule.settings')
      -&gt;set('mymodule_enabled_content_types', $form_state-&gt;getValue('mymodule_enabled_content_types'))
      -&gt;save();

    parent::submitForm($form, $form_state);
  }
}
...
You are creating your checkbox options as an associative array of node type (bundle) IDs as keys and their labels as values.

When this form is submitted, checked checkboxes submit as key =&gt; key. So the stored information (I suppose 'rss_url' in your question is intended to being 'mymodule_enabled_content_types') is similar to:

mymodule_enabled_content_types:
  article: article
  page: page
  custom: custom


As the keys of the submitted values are unknown before submission, and the values clearly are strings, this is a sequence of strings (compare https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata#properties). The correct schema definition is:

mymodule.settings:
  type: config_object
  label: 'My Module settings'
  mapping: 
    mymodule_enabled_content_types:
      type: sequence
      label: 'Enabled Content types'
      sequence:
        type: string


After changing your schema definition and rebuilding your caches, your form submit handler should work just fine and the configuration being saved using its correct data types.