Reputation: 3658
I am relatively new to sonata and I need to implement a new Admin module with a similar structure to following: Lets say I have a typical Shopping Cart scenario where I have an Order entity and an OrderItem, (one to many relation).
In The List view, It should display all the order items, but in the Create action, it will allow to create a Order entity (with an embeded form for creating order items).
Do I need to create 2 admin modules? If yes, how can change the "create" button to point to the other admin?
Thanks for your help.
Upvotes: 0
Views: 483
Reputation: 313
You create you'r entities, Order and OrderItem. Then you need to create a specefic Admin Class for each. When you build the Order form mapper, you need to embed the order item collection, something like this should do the job:
->with('OrderItem')
->add('orderItem', 'sonata_type_collection', array(
'label' => 'Item',
'required' => true,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
),array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
))
I dont get it, why whould you change the create button ?
Upvotes: 1