Reputation: 1572
I create the form with Symfony Form ChoiceType but there is one issue, for example i have a array like this
array('M' => 'Male', 'F' => 'Female')
I want key as key but Symfony Form Choice Type get key as value and value as key in dropdown
<option value="Male">M</option>
<option value="Female">F</option>
but i don't want like this, i want output like following :-
<option value="M">Male</option>
<option value="F">Female</option>
Sorry for my english
Upvotes: 1
Views: 430
Reputation: 2310
Symfony ChoiceType
uses the array key as the option name and the array value as the option value, there's no way around it if you wish to keep using the built in ChoiceType
.
You will need to array_flip
the original array before using it in the form type.
Upvotes: 1