How should we define a config variable of type multidimensional array in schema.yml file ?

Something which I figured out from drupal documentation is that we can define either type mapping for string value of array or type sequence for integer value or string value of array.

But I'm not sure how should we define for our multidimensinal array, as we have to mention the key first and then the type of value which can be assigned to that key.

For reference I'm adding the following e.g code

type: config_entity
label: 'Image style'
  type: string
  type: label
  label: 'Label'
  type: sequence
    type: mapping
        type: string
        type: image.effect.[%parent.id]
        type: integer
        type: string

Any suggestions?

  • 1
    There is a module which may help you to validate you configuration schema. drupal.org/project/config_inspector – ya.teck Aug 25 '17 at 11:04
  • Anything that has specific keys has to be mapping. Sequence is purely for anonymous arrays. If you will have array with specific keys that you do not know upfront, it has to be sequence. – user21641 Aug 25 '17 at 13:18
  • @IvanJaros So is it necessary to define those upfront keys also? – Gaurav Rajdeo Aug 25 '17 at 14:34
  • In other words, sequence for indexed array, mapping form associative array. Both can be nested. – ya.teck Aug 26 '17 at 5:47
  • can you edit with your array structure? – Adrian Cid Almaguer Aug 28 '17 at 17:57

Your Answer

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

Browse other questions tagged or ask your own question.