Forms symfony2嵌入式集合编辑表单

Forms symfony2嵌入式集合编辑表单,forms,symfony,doctrine-orm,Forms,Symfony,Doctrine Orm,我在表单中创建了另一个实体的嵌入式集合,其想法是,当您编辑或删除“demand”时,也会编辑属于它的“products”,我的创建表单是可以的,但编辑表单时会出现错误: 可捕获致命错误:传递给MaisAlimentos\DemandBundle\Entity\Demanda::setProdutosDemanda()的参数1必须是Doctrine\Common\Collections\ArrayCollection的实例,给定的Doctrine\ORM\PersistentCollection的

我在表单中创建了另一个实体的嵌入式集合,其想法是,当您编辑或删除“demand”时,也会编辑属于它的“products”,我的创建表单是可以的,但编辑表单时会出现错误:

可捕获致命错误:传递给MaisAlimentos\DemandBundle\Entity\Demanda::setProdutosDemanda()的参数1必须是Doctrine\Common\Collections\ArrayCollection的实例,给定的Doctrine\ORM\PersistentCollection的实例,在第347行的/var/www/maa/vendor/symfony/src/symfony/Component/Form/Util/PropertyPath.php中调用,并在/var/www/maa/src/MaisAlimentos/DemandaBundle/Entity/Demanda.php第130行中定义

我在一些论坛上读到,解决方案是删除setter类型,我得到了其他错误:

可捕获致命错误:无法将/var/www/maa/src/MaisAlimentos/DemandaBundle/Entity/Demanda.php第136行中的类Doctrine\ORM\PersistentCollection的对象转换为字符串

我的代码


好的,您已经找到了原始问题的解决方案

第二个错误来自打字/复制粘贴错误

在pastebin代码的第162行中:

$this->$produtosDemanda = $produtosDemanda;
应该是

$this->produtosDemanda = $produtosDemanda;
因此,在
$this->
之后没有
$
符号