简体   繁体   English

奏鸣曲管理员编辑表格多对多不起作用 - symfony2.1.6

[英]Sonata Admin edit form many to many not working - symfony2.1.6

I am having a problem with implementing the many to many relationship in the sonata admin edit form, with the following structure. 我在奏鸣曲管理编辑表单中实现多对多关系时遇到问题,具有以下结构。

purchase (id, total_price, discount, created_at)
purchase_product (purchase_id, product_id, quantity)
product (id, title, desc, price, thumbnail, created_at)

I have seen many threads and have tried the solutions listed in them. 我见过很多线程,并尝试过其中列出的解决方案。 I have tried 我试过了

->add('products', 'sonata_type_model', array('by_reference' => false))

I get the following error 我收到以下错误

No entity manager defined for class Doctrine\ORM\PersistentCollection 

Then when i couldn't find a way to solve this, I switched to 然后,当我找不到解决这个问题的方法时,我切换到了

->add('products', 'sonata_type_collection', array(), array('edit' => 'inline', 'inline' => 'table')

I got the following error 我收到以下错误

INVALID MODE type : sonata_type_collection - mapping : 8 

I am also unable to figure out how to get and display the quantity from the purchase_product table. 我也无法弄清楚如何从purchase_product表中获取和显示数量。

Any pointers and help is highly appreciated. 任何指针和帮助都非常感谢。

您可以尝试添加'expanded'=> true和'multiple'=> true

->add('products', 'sonata_type_model', array('expanded' => true, 'by_reference' => false, 'multiple' => true))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM