1
->add('city', EntityType::class, array(
'class' => 'CFCWalesUserBundle:Zone',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('c')
->where('c.country = :country')
->setParameter('country', $this->country)
->orderBy('c.name', 'ASC');
},
'choice_label' => 'name',
'empty_data' => null,
'attr' => array(
'class' => 'form-control'
)
))
形式的一部分,下面是用戶實體區域的部分:
/**
* @ORM\Column(name="city", type="integer")
*/
private $city;
當一個選項是從城市下拉列表中選擇,我提交表單後出現此錯誤:
Catchable Fatal Error: Object of class CFCWales\UserBundle\Entity\Zone could not be converted to string
我希望$ city存儲整數值而不是對象。