I have some problem. How set default value for choice or enitity form type ()? I don't need prefffered choice or empty value. How to add this options?
2 Answers
Use the data option. Details are in the reference.
1 Comment
Chadwick Meyer
do you know anything about the
empty_data option for form fields? I'm not sure if this question is looking for that, but I am, and I can't get it to work. See: stackoverflow.com/questions/24792285/…Default values are no options, it uses the second argument of the form constructor.
5 Comments
rtyshyk
Yes, but my form class don't entity object. I have some filter with parameters.
greg0ire
The first sentence of your first comment seems to be lacking a word.
rtyshyk
I have custom filters, for example type, area, rooms as array and city, region, district as entity. After search i want save filter values for next search.
greg0ire
When I said trying a simple array, I meant trying something like this :
array('type' => 'image', 'area' => 'jungle', rooms => array('room1', 'room2', 'city' => new City('Paris')));rtyshyk
Thanks, but I done this save filter using js and url parameters :)