1
我在我的一個項目中使用了FOSUserBundle。Symfony2:Form throws「傳遞給Doctrine Common Collections ArrayCollection :: __ construct()的參數1必須是一個數組,對象給出」on submit
我已經建立了一個基於對象Employee(與RoleGroup有許多關係)的表單。
這裏是形式(的一部分):
$builder->add('groups', 'entity', array(
'class' => 'MMAAuthBundle:RoleGroup',
'choices' => $this->groups,
'property' => 'name',
'label' => 'Groups',
'expanded' => true,
'attr' => array("multiple" => true)
));
當我提交表單,我得到這個錯誤在Profiler:
at ErrorHandler ->handle ('4096', 'Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given, called in /home/mihai/intranet/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 528 and defined', '/home/mihai/intranet/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php', '47', array())
in /home/mihai/intranet/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php at line 47
我怎樣才能讓形式返回ArrayCollection
,而不是RoleGroup
對象?
我剛纔this問題,但現在我卡在這裏。目前不
謝謝你,就像一個魅力! – MihaiM