In my ConfigFormBase derived class I want to add select list to settings form.

How should I declare it in mymod.config.yml file?

I've tried:

  type: config_object
  label: 'Settings'
      type: checkbox
      label: 'Turn on test mode'
      type: multiple
      label: 'Action site'
        - 1
        - 22
        - 34
        - 56
        - 107
        - 168
        - 181
        - 209
        - 228

and can I specify list as key -> value pairs also?


Config schema doesn't know about allowed values. It's a about the structure of the stored configuration, not how it is displayed to the user.

It's up to you to implement the form for that, using e.g. a #type selection and #options.

For the config schema, it's type: boolean, not type checkbox. And type: integer, what you tried to use there doesn't exist.

|improve this answer|||||
  • Do you know good reference about settings yml structure? (Besides drupal.org) – Codium Aug 16 '16 at 8:15
  • Schema structure is little not intuitive for me, e.g: two similar types: string and text, strange... – Codium Aug 16 '16 at 8:22
  • Ok, I've found something useful at drupal.org: drupal.org/node/1905070 – Codium Aug 16 '16 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.