[英]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.