【发布时间】:2015-11-20 06:13:14
【问题描述】:
我有三个班级,
OrderAdmin、ProductAdmin、OrderHasEquipmentAdmin。
Order 需要将与该产品相关的Product 和Equipment 添加到中间表OrderHasEquipment 中。
我可以添加新产品,但是当我尝试添加 OrderHasEquipment 时,它会显示我在数据库中拥有的所有设备,我只想显示该产品可用的设备并附加到该订单。
关系是
订单 -> manyToOne -> 产品
Order -> oneToMany -> OrderHasEquipment (因为我需要一个中间实体来与奏鸣曲管理员sonata_type_collection 和sonata_type_model_list 合作)
产品 -> manyToMany -> 设备
So, when creating/editing an Order, it shows up a choice list with Products, I need a behaviour that when a Product is selected, OrderHasEquipment (that is a sonata_type_collection field sonata_type_model_list 里面是中间实体),请允许我只添加一个与所选 Product 相关的 Equipment 项目。
有什么办法吗?
【问题讨论】:
-
你用过->with('Relation table')吗?
-
现在,我试图使用孩子和父母的东西,但没有像预期的那样工作。
->with('Relation table')的东西怎么样? -
您为 OrderHasEquipment 设置了所有正确的关系吗?
-
是的,关系正确,表格运行良好,我只想显示所选产品的设备并将它们分配给订单,这是我不知道如何实现的工作流程。跨度>
标签: php symfony sonata-admin