File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,37 @@ is the item's label and the array value is the item's value::
123
123
able to use values that are not integers or strings (but e.g. floats
124
124
or booleans).
125
125
126
+ choices_as_values
127
+ ~~~~~~~~~~~~~~~~~
128
+
129
+ **type **: ``boolean `` **default **: false
130
+
131
+ .. versionadded :: 2.7
132
+
133
+ The ``choices_as_values `` option of ChoiceType was introduced in Symfony 2.7.
134
+
135
+ The ``choices_as_values `` option was introduced to ensure backward compatibility with the
136
+ modified handling of the ``choices `` optio. Being set to ``false `` the choices array
137
+ will be read as values mapping the keys. Setting the option to ``true `` will enable the new
138
+ handling of the choices mapping keys to values.
139
+
140
+ * Before 2.7::
141
+ $builder->add('gender', 'choice', array(
142
+ 'choices' => array('m' => 'Male', 'f' => 'Female'),
143
+ 'choices_as_values' => false,
144
+ ));
145
+
146
+ * Optional since 2.7::
147
+ $builder->add('gender', 'choice', array(
148
+ 'choices' => array('Male' => 'm', 'Female' => 'f'),
149
+ 'choices_as_values' => true,
150
+ ));
151
+
152
+ * Default for 3.0::
153
+ $builder->add('gender', 'choice', array(
154
+ 'choices' => array('Male' => 'm', 'Female' => 'f'),
155
+ ));
156
+
126
157
.. caution ::
127
158
128
159
The ``choices_as_values `` option will be removed in Symfony 3.0, where
You can’t perform that action at this time.
0 commit comments