2012-08-31 84 views
3

我在表單中創建了另一個實體的嵌入式集合,這個想法是,當您編輯或刪除「需求」時也會編輯屬於它的「產品」,我的創建表單是好的,但編輯它給人的錯誤:symfony2嵌入式集合編輯表單

Catchable Fatal Error: Argument 1 passed to MaisAlimentos\DemandaBundle\Entity\Demanda::setProdutosDemanda() must be an instance of Doctrine\Common\Collections\ArrayCollection, instance of Doctrine\ORM\PersistentCollection given, called in /var/www/maa/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 347 and defined in /var/www/maa/src/MaisAlimentos/DemandaBundle/Entity/Demanda.php line 130

我在一些論壇上閱讀,解決方法是刪除二傳手的類型,我還有其他的錯誤:

Catchable Fatal Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string in /var/www/maa/src/MaisAlimentos/DemandaBundle/Entity/Demanda.php line 136

我的代碼

http://pastebin.com/WeGcHyYL

回答

2

好的,所以你已經找到了你原來的問題的解決方案。

第二個來自錯字/複製粘貼錯誤。

在你的引擎收錄代碼行162:

$this->$produtosDemanda = $produtosDemanda; 

應該

$this->produtosDemanda = $produtosDemanda; 

所以沒有$跡象$this->後。

+0

對不起noob問題,錯誤是這樣的$ $ $ this-> –