0
是否可以迭代Symfony 3中的ChoiceType值?我可以設置好這些值,但是他們只是輸出一個我無法控制的大塊。我想遍歷每個值和格式化/放在桌子/ DIV /列等如何格式化/控制Symfony ChoiceType的輸出
$builder->add('tOptions', ChoiceType::class, array(
'choices' => array(
'one' => true,
'two' => true,
'three' => true,
'four' => true,
'five' => true,
),
'expanded' => true,
'multiple' => true,
'required' => false,
));
注:我不是在樹枝輸出,剛剛在PHP。
echo $view['form']->widget($form['tOptions']);
結果:
<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>
怎樣一個迭代對這些輸入選項,以便在div來包裝每個或分成兩個偶數列等
謝謝。終於到達那裏了。在這種情況下,它是choice_widget_expanded文件。 – BrocolliRob