0
votes

I have three classes,

OrderAdmin, ProductAdmin, OrderHasEquipmentAdmin.

Order needs to add a Product and Equipment related to that product into an intermediate table OrderHasEquipment.

I can add a new Product, but when I try to add an OrderHasEquipment, it shows every Equipment I have in my DB, I only want to show the equipment available for that product and append to that Order.

Relations are

Order -> manyToOne -> Product

Order -> oneToMany -> OrderHasEquipment (because I need an intermediate Entity to work with sonata admin sonata_type_collection and sonata_type_model_list)

Product -> manyToMany -> Equipment

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 with sonata_type_model_list inside because the intermediate entity), allow me to only add an Equipment item related to that Product selected.

Any way of doing this?

1
Do you used ->with('Relation table')? - SarDau Mort
Now, I was trying to use child and parent stuff but doesn't work as spected. How is that ->with('Relation table') stuff? - Robert W. Hunter
Do you set all right relations for OrderHasEquipment? - SarDau Mort
Yes, relations are correct, forms are working perfectly, what I want is to show only Equipments for selected Product and assing them to Order, that's the workflow I don't know how to achieve. - Robert W. Hunter

1 Answers

0
votes

If all relations right:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('Equipment') //name from Entity
        ;
    }