Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms Symfony2:表单抛出“;传递给Doctrine\Common\Collections\ArrayCollection::uu construct()的参数1必须是数组,对象为“给定”;提交_Forms_Symfony_Fosuserbundle - Fatal编程技术网

Forms Symfony2:表单抛出“;传递给Doctrine\Common\Collections\ArrayCollection::uu construct()的参数1必须是数组,对象为“给定”;提交

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

我正在我的一个项目中使用FOSUserBundle

我已经基于对象Employee构建了一个表单(该对象具有多个角色组)

以下是表格(部分):

提交表单时,我在探查器中遇到以下错误:

    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