Forms Symfony2:表单抛出“;传递给Doctrine\Common\Collections\ArrayCollection::uu construct()的参数1必须是数组,对象为“给定”;提交
我正在我的一个项目中使用FOSUserBundle 我已经基于对象Employee构建了一个表单(该对象具有多个角色组) 以下是表格(部分): 提交表单时,我在探查器中遇到以下错误:Forms Symfony2:表单抛出“;传递给Doctrine\Common\Collections\ArrayCollection::uu construct()的参数1必须是数组,对象为“给定”;提交,forms,symfony,fosuserbundle,Forms,Symfony,Fosuserbundle,我正在我的一个项目中使用FOSUserBundle 我已经基于对象Employee构建了一个表单(该对象具有多个角色组) 以下是表格(部分): 提交表单时,我在探查器中遇到以下错误: at ErrorHandler ->handle ('4096', 'Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given, call
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
如何使表单返回数组集合
,而不是角色组
对象
我以前确实遇到过问题,但现在我被困在这里。您的表单当前不是一个多表单,因此将单个
角色组对象而不是角色组对象数组传递给集合的构造函数
是一个表单选项。。。而不是HTML属性。因此
$builder->add('groups', 'entity', array(
// This would only render a multiple="true" inside the fields HTML tag
'attr' => array("multiple" => true)
。。。应该是
$builder->add('groups', 'entity', array(
// multiple option not wrapped by attribute is correct
"multiple" => true
$builder->add('groups', 'entity', array(
// multiple option not wrapped by attribute is correct
"multiple" => true