We have a custom module, mymodule that has an admin form where it stores field of type: number and select. I need to create a mymodule/config/schema/mymodule.schema.yml file, but don't know what to put in there.

What is the correct way to define the mymodule.schema.yml file for the two field types?


class MyModuleForm extends ConfigFormBase {
  protected function getEditableConfigNames() {
    return [
  public function getFormId() {
    return 'mymodule';
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('mymodule.setting');
    $form['field_select'] = [
      '#type' => 'select',
      '#title' => 'Selection',
      '#description' => 'Pick one.',
      '#options' => [
        '1' => $this->t('option 1'),
        '2' => $this->t('option 2'),
      '#default_value' => $config->get('field_select'),

    $form['field_num'] = [
      '#type' => 'number',
      '#title' => $this->t('Some number'),
      '#description' => 'Indicate number.',
      '#default_value' => $config->get('field_num'),

Here is what I was thinking but it does not look correct.


  type: config_object
  label: 'My form'
      type: integer
      label: 'My number'
      type: string
      label: 'My selection'

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.