1

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

image.style.*: type: config_entity label: 'Image style' mapping: name: type: string label: type: label label: 'Label' effects: type: sequence sequence: type: mapping mapping: id: type: string data: type: image.effect.[%parent.id] weight: type: integer uuid: type: string 

Any suggestions?

5
  • 1
    There is a module which may help you to validate you configuration schema. drupal.org/project/config_inspector Commented Aug 25, 2017 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. Commented Aug 25, 2017 at 13:18
  • @IvanJaros So is it necessary to define those upfront keys also? Commented Aug 25, 2017 at 14:34
  • In other words, sequence for indexed array, mapping form associative array. Both can be nested. Commented Aug 26, 2017 at 5:47
  • can you edit with your array structure? Commented Aug 28, 2017 at 17:57

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.