Skip to content

Commit a74dddd

Browse files
committed
minor #6459 Remove choices as values in 3.0 (weaverryan)
This PR was merged into the 3.0 branch. Discussion ---------- Remove choices as values in 3.0 | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 3.0+ | Fixed tickets | n/a I think we must have just forgotten to remove this option! Commits ------- 3d4ae1e Removing all instances of choices_as_values in 3.0
2 parents dc03f45 + 3d4ae1e commit a74dddd

File tree

5 files changed

+3
-42
lines changed

5 files changed

+3
-42
lines changed

reference/forms/types/choice.rst

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
1919
| | - `choice_name`_ |
2020
| | - `choice_translation_domain`_ |
2121
| | - `choice_value`_ |
22-
| | - `choices_as_values`_ |
22+
| | - `choices_as_values`_ (deprecated) |
2323
| | - `expanded`_ |
2424
| | - `group_by`_ |
2525
| | - `multiple`_ |
@@ -167,8 +167,6 @@ is the item's label and the array value is the item's value::
167167

168168
$builder->add('inStock', ChoiceType::class, array(
169169
'choices' => array('In Stock' => true, 'Out of Stock' => false),
170-
// always include this
171-
'choices_as_values' => true,
172170
));
173171

174172
.. include:: /reference/forms/types/options/choice_attr.rst.inc
@@ -195,39 +193,8 @@ would replace the ``choices`` option.
195193
choices_as_values
196194
~~~~~~~~~~~~~~~~~
197195

198-
**type**: ``boolean`` **default**: false
199-
200-
The ``choices_as_values`` option was added to keep backward compatibility with the
201-
*old* way of handling the ``choices`` option. When set to ``false`` (or omitted),
202-
the choice keys are used as the underlying value and the choice values are shown
203-
to the user.
204-
205-
* Before 2.7 (and deprecated now)::
206-
207-
$builder->add('gender', 'choice', array(
208-
// Shows "Male" to the user, returns "m" when selected
209-
'choices' => array('m' => 'Male', 'f' => 'Female'),
210-
// before 2.7, this option didn't actually exist, but the
211-
// behavior was equivalent to setting this to false in 2.7.
212-
'choices_as_values' => false,
213-
));
214-
215-
* Since 2.7::
216-
217-
$builder->add('gender', ChoiceType::class, array(
218-
// Shows "Male" to the user, returns "m" when selected
219-
'choices' => array('Male' => 'm', 'Female' => 'f'),
220-
'choices_as_values' => true,
221-
));
222-
223-
In Symfony 3.0, the ``choices_as_values`` option doesn't exist, but the ``choice``
224-
type behaves as if it were set to true:
225-
226-
* Default for 3.0::
227-
228-
$builder->add('gender', ChoiceType::class, array(
229-
'choices' => array('Male' => 'm', 'Female' => 'f'),
230-
));
196+
This option is deprecated and you should remove it from your 3.x projects (removing
197+
it will have *no* effect). For its purpose in 2.x, see the 2.7 documentation.
231198

232199
.. include:: /reference/forms/types/options/expanded.rst.inc
233200

reference/forms/types/options/choice_attr.rst.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ If an array, the keys of the ``choices`` array must be used as keys::
1818
'No' => false,
1919
'Maybe' => null,
2020
),
21-
'choices_as_values' => true,
2221
'choice_attr' => function($val, $key, $index) {
2322
// adds a class like attending_yes, attending_no, etc
2423
return ['class' => 'attending_'.strtolower($key)];

reference/forms/types/options/choice_label.rst.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ more control::
1616
'no' => false,
1717
'maybe' => null,
1818
),
19-
'choices_as_values' => true,
2019
'choice_label' => function ($value, $key, $index) {
2120
if ($value == true) {
2221
return 'Definitely!';
@@ -48,7 +47,6 @@ If your choice values are objects, then ``choice_label`` can also be a
4847
new Status(Status::NO),
4948
new Status(Status::MAYBE),
5049
),
51-
'choices_as_values' => true,
5250
'choice_label' => 'displayName',
5351
));
5452

reference/forms/types/options/group_by.rst.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Take the following example::
2222
'1 week' => new \DateTime('+1 week'),
2323
'1 month' => new \DateTime('+1 month')
2424
),
25-
'choices_as_values' => true,
2625
'group_by' => function($val, $key, $index) {
2726
if ($val <= new \DateTime('+3 days')) {
2827
return 'Soon';

reference/forms/types/options/preferred_choices.rst.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ you can list the most popular on top, like Bork Bork and Pirate::
1717
'Bork' => 'muppets',
1818
'Pirate' => 'arr'
1919
),
20-
'choices_as_values' => true,
2120
'preferred_choices' => array('muppets', 'arr')
2221
));
2322

@@ -34,7 +33,6 @@ be especially useful if your values are objects::
3433
'1 week' => new \DateTime('+1 week'),
3534
'1 month' => new \DateTime('+1 month')
3635
),
37-
'choices_as_values' => true,
3836
'preferred_choices' => function ($val, $key) {
3937
// prefer options within 3 days
4038
return $val <= new \DateTime('+3 days');

0 commit comments

Comments
 (0)