in my form type i have this :
$builder
->add('options', 'choice', [
'choices' => $choices,
'multiple' => true,
'expanded' => true,
'label' => false
])
;
choices is an array :
$choices = [
'val1' => 'val1',
'val2' => 'val2',
'val3' => 'val3'
];
Great ! now i want to categorized my choices with an array like this:
$choices = [
'label1' => [
'val1' => 'val1',
'val2' => 'val2',
],
'label2' => [
'val3' => 'val3',
'val4' => 'val4',
],
'label3' => [
'val5' => 'val5',
'val6' => 'val6',
],
];
So i want result like below
what is the best way to achieve this?