Is it possible to iterate over ChoiceType values in Symfony 3? I can setup the values fine, but they just output in big block for which i can't control. I would like to loop over each value and format it/put in table/div/columns etc.
$builder->add('tOptions', ChoiceType::class, array(
'choices' => array(
'one' => true,
'two' => true,
'three' => true,
'four' => true,
'five' => true,
),
'expanded' => true,
'multiple' => true,
'required' => false,
));
Note: I am not outputting in twig, just in PHP.
echo $view['form']->widget($form['tOptions']);
Results in:
<div id="t_options_tOptions">
<input type="checkbox" id="t_options_tOptions_0" name="t_options[tOptions][]" value="0">
<label for="t_options_tOptions_0">one</label>
<input type="checkbox" id="t_options_tOptions_1" name="t_options[tOptions][]" value="1">
<label for="t_options_tOptions_1">two</label>
<input type="checkbox" id="t_options_tOptions_2" name="t_options[tOptions][]" value="2">
<label for="t_options_tOptions_2">three</label>
<input type="checkbox" id="t_options_tOptions_3" name="t_options[tOptions][]" value="3">
<label for="t_options_tOptions_3">four</label>
<input type="checkbox" id="t_options_tOptions_4" name="t_options[tOptions][]" value="4">
<label for="t_options_tOptions_4">five</label>
</div>
How does one iterate over these input options, in order to wrap each in div or split into two even columns etc.