symfony2嵌入式集合编辑表单

时间:2012-08-31 16:58:01

标签: forms symfony doctrine-orm

我在表单中创建了另一个实体的嵌入式集合,其想法是当您编辑或删除“需求”时也会编辑属于它的“产品”,我的创建表单没问题,但是编辑它会产生错误:

  

捕获致命错误:传递给MaisAlimentos \ DemandaBundle \ Entity \ Demanda :: setProdutosDemanda()的参数1必须是Doctrine \ Common \ Collections \ ArrayCollection的实例,Doctrine \ ORM \ PersistentCollection的实例,在/ var /中调用www / maa / vendor / symfony / src / Symfony / Component / Form / Util / PropertyPath.php,第347行,并在/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

1 个答案:

答案 0 :(得分:2)

好的,所以你找到了原始问题的解决方案。

第二个来自拼写错误/复制粘贴错误。

在pastebin代码的第162行:

$this->$produtosDemanda = $produtosDemanda;

应该是

$this->produtosDemanda = $produtosDemanda;

$之后没有$this->符号。

相关问题