【发布时间】:2018-03-01 10:08:42
【问题描述】:
我对表单中ChoiceType 的返回码有疑问:
$form->add('choix',ChoiceType::class, array(
'choices' => $voila ,
'multiple'=>false,'label'=>$nom,'expanded'=>true));
此代码调用实体中的 setChoix() 函数:
public function
setChoix(\AppBundle\Entity\Magasin\Caracteristique\ChoixCaracteristique
$choix = null)
{
$this->choix = $choix;
return $this;
}
之前,我没有使用 ChoiceType 而是使用 EntityType,所以,它起作用了:
$form->add('choix', EntityType::class, array(
'class' => 'AppBundle:Magasin\Caracteristique\ChoixCaracteristique',
'choices' => $choix,
'placeholder' => 'Choix',
'label' => $label,
'required' => false
));
我的问题是“
如何 CAST ChoiceType 避免类型问题
(EntityType使用AppBundle:Magasin\Caracteristique\ChoixCaracteristique类型,所以可以)
感谢您的帮助!
【问题讨论】:
标签: symfony