我正在尝试通过formbuilder制作单选按钮。
我在实体中有整数列。
需要1-5的数字。
起初我试过这个。
$form = $this->createFormBuilder($myEntity)
->add('point',"choice",array(
'data' => array(
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5'
),multiple => 'false'
))
它显示列表框而不是单选按钮。 我该如何制作单选按钮?
答案 0 :(得分:2)
您需要使用expanded => true
才能让单选按钮在choices
选项中添加您的选择数组而不是数据选项
$form = $this->createFormBuilder($myEntity)
->add( 'point', "choice", array(
'choices' => array(
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5'
)
,'expanded' => true
));