繁体   English   中英

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

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

我在奏鸣曲管理编辑表单中实现多对多关系时遇到问题,具有以下结构。

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

我见过很多线程,并尝试过其中列出的解决方案。 我试过了

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

我收到以下错误

No entity manager defined for class Doctrine\ORM\PersistentCollection 

然后,当我找不到解决这个问题的方法时,我切换到了

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

我收到以下错误

INVALID MODE type : sonata_type_collection - mapping : 8 

我也无法弄清楚如何从purchase_product表中获取和显示数量。

任何指针和帮助都非常感谢。

您可以尝试添加'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