I am defining a new render element which one of the property is an array:

'#property' => [
   'foo' => 'bar,
   'some' => 'value',
]

I am struggling to provide a webform element configuration for this kind of property.

My idea was to add form elements to 'foo' and 'some' separately, but these get added as '#foo' and '#some' properties under the element.

If I don't define 'foo' and 'some' as default properties, the element doesn't appear at all.

I guess I could use some cryptic property like property_foo and then convert it in the prepare, but I wonder if there's a better way of doing that hacking what webform is already doing behind the scenes by assuming a one to one config to property.

Or maybe I am missing something ,quite a bit of code to debug/digest.

Comments

hanoii created an issue. See original summary.

jrockowitz’s picture

I use double underscores for subelement properties #{subelement}__{property}.

The Webform element UI will does properties that are array but you have to define a form element that accepts an array as the #default_value. For example, you could use the 'webform_codemirror' element with #mode: yaml which allows you to edit the array.

jrockowitz’s picture

Status: Active » Closed (works as designed)