I'm using a form(parent form) with a collection field type(child forms). Each type in the collection is a form that contains some choice fields, I want to filter this field choices using query_builder parameter for join with other entities ect. I know how to pass parameters to parent form from controller, but how to pass parameters to each item in the collection (child forms)?
What you want is a data transformer. The data transformer takes data from your sub forms allows you to do queries to the database from inside it and pass 1 final result out the end. I had to do this the other day with country and postal code to find a valid postal code in a country.
Here's the link to the cookbook info that will show you how to use it.
http://symfony.com/doc/current/cookbook/form/data_transformers.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With