Symfony 3中有些我不了解的东西
在我的formType.php上(其中“ cible”是布尔值):
->add('cible', ChoiceType::class, array(
'required' => false,
'expanded' => true,
'choices' => array(
'yes' => 1,
'no' => 0
),
'placeholder' => false,
))
重新调整
<select id="search_sample_to_order_cible" name="search_sample_to_order[cible]">
<option value="1">Oui</option>
<option value="0">Non</option>
</select>
好。但是我想要单选按钮,当我通过时将其展开为true:
->add('cible', ChoiceType::class, array(
'required' => false,
'expanded' => false,
'choices' => array(
'yes' => 1,
'no' => 0
),
'placeholder' => false,
))
no选项的值变成'1',我不想要!
<label for="search_sample_to_order_cible_0" class="radio">
<input id="search_sample_to_order_cible_0" name="search_sample_to_order[cible]" value="1" type="radio">yes
</label>
<label for="search_sample_to_order_cible_1" class="radio">
<input id="search_sample_to_order_cible_1" name="search_sample_to_order[cible]" value="1" type="radio">no
</label>