我试着写:
<?php
add('gender',
RadioType::class,array('choices'=>
array('f'=>female','m'=>'male')
)
)
?>
但我收到以下错误
&#34;选择&#34;不是Attriibute
答案 0 :(得分:2)
无线电类型不提供在不同选项之间进行选择的方法。为此,您必须使用choice type并将expanded option设置为true
:
$builder->add('gender', ChoiceType::class, array(
'choices' => array('female' => 'f', 'male' => 'm'),
'choices_as_values' => true,
'expanded' => true,
))
答案 1 :(得分:0)
检查单引号'
,其female
选项缺失:
<?php
add('gender',
RadioType::class,array('choices'=>
array('f'=>'female','m'=>'male')
)
)
?>