的Symfony 2.8.2
按照Symfony的文档“中选择选项是一个数组,数组键是项目的标签和数组值项的数值”
但具有下列形式我看到了完全相反:
$filterForm = $this->createFormBuilder()
->add('vendorName', ChoiceType::class, array(
'expanded' => true,
'multiple' => true,
'choices' => array('label' => 'value') // <-- HERE
))
->add('filter', SubmitType::class, array('label' => 'Filter'))
->getForm();
呈现这样的:
是文档错了吗?或者我没有得到它的权利?
感谢您指出。所以我想我的选项要么将choices_as_values设置为true,要么升级到3.x.请您反映,在您的回答 –
@StasParshin更正中,请将choices_as_values设置为true,以便将键作为标签。从v3开始,作为标签的键是默认值。 – jah