我在表单中创建了另一个实体的嵌入式集合,其想法是,当您编辑或删除“demand”时,也会编辑属于它的“产品”,我的创建表单是可以的,但是它的编辑会产生错误:
可捕获的致命错误:传递给MaisAlimentos\DemandaBundle\Entity\Demanda::setProdutosDemanda()的参数1必须是Doctrine\ passed \Collection\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的类型,我得到了其他错误:
可捕获的致命错误:无法将类Doctrine\ORM\PersistentCollection的对象转换为/var/www/maa/src/MaisAlimentos/DemandaBundle/Entity/Demanda.php第136行中的字符串
我的代码
http://pastebin.com/WeGcHyYL
发布于 2012-08-31 19:32:21
好了,你找到了原来问题的解决方案。
第二个错误来自错误/复制粘贴错误。
在您的pastebin代码的第162行中:
$this->$produtosDemanda = $produtosDemanda;应该是
$this->produtosDemanda = $produtosDemanda;所以在$之后没有$this->的迹象。
https://stackoverflow.com/questions/12219606
复制相似问题