I have a frontend form with one large select field with optgroups. These are the names of five parent pages and then underneath their child pages are listed as options. How do I pass this structure to data-options@ in the field’s definition?
I tried
PHP
$arrOptions = [
'Optgroup 1' => [
'1-1' => 'Group 1 Option 1',
'1-2' => 'Group 1 Option 2',
'1-3' => 'Group 1 Option 3',
],
'Optgroup 2' => [
'2-1' => 'Group 2 Option 1',
'2-2' => 'Group 2 Option 2',
'2-3' => 'Group 2 Option 3',
],
];
return $arrOptions;
but that just gets output as <optgroup label="1-1"></optgroup><optgroup label="2-1"></optgroup>.
Is it even doable? If so, how?