I am working on a sonata admin panel using symfony 3.3. I have two entities Category
and Chalets
. They are associated many to many so that One category have many Chalets and Chalet can be associated to many Categories.
I want the functionality in my admin panel to show the Chalets based on Category choosen from dropdown and a button to replicate the same to add another category with Chalets and so on.
The picture below will give you the deep insights. Picture of my current functionality
Right now all the Chalets added in the database are visible in the dropdown I want to show only the selected category Chalets to be shown. Alson, the button(Add more) will replicate the Category and Chalet to repeat the process. Thanks!
What you need is sonata_type_collection field.
It will look a bit different out of the box, but capabilities is exactly what you want.
So, how it works:
So, all this will work without any custom templates/Ajax calls.
P S. If you still want to customize UI - easier to do it with JavaScript.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.