0
的Symfony documentation说,你应该使用使用ChoiceType这样的:只有Symfony的形式ChoiceType值
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
$builder->add('isAttending', ChoiceType::class, array(
'choices' => array(
'Maybe' => null,
'Yes' => true,
'No' => false,
),
));
但是,因为我的价值观是很简单的像钥匙,我愿做这样的事情:
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
$builder->add('titre', ChoiceType::class, array(
'choice_value' => array(
'Pr', 'Dr', 'Mr', 'Mrs'
),
))
我该如何做到这一点?
如果我不能,背后的好理由是什么?
太好了!我一直在寻找一个更symfony的十岁上下的方式做到这一点,但是这只是正常工作:-) –