Skip to content

Commit 0221dd4

Browse files
committed
feature #9598 [Form] Fixed ChoiceType trim option (HeahDude, javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- [Form] Fixed ChoiceType trim option Ref symfony/symfony#26932. Commits ------- 2dd6c56 fixup typo 360066d fixup option links 6631665 fixup @xabbuh's comment proper choice type trim file 8bfa059 Reword bbca3b0 [Form] Fixed ChoiceType trim option
2 parents 4a56034 + 2dd6c56 commit 0221dd4

File tree

8 files changed

+29
-1
lines changed

8 files changed

+29
-1
lines changed

reference/forms/types/choice.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
3030
| Overridden | - `compound`_ |
3131
| options | - `empty_data`_ |
3232
| | - `error_bubbling`_ |
33+
| | - `trim`_ |
3334
+-------------+------------------------------------------------------------------------------+
3435
| Inherited | - `attr`_ |
3536
| options | - `by_reference`_ |
@@ -106,7 +107,7 @@ method::
106107
'choice_attr' => function($category, $key, $index) {
107108
return ['class' => 'category_'.strtolower($category->getName())];
108109
},
109-
110+
110111
'group_by' => function($category, $key, $index) {
111112
// randomly assign things into 2 groups
112113
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
@@ -323,6 +324,8 @@ error_bubbling
323324
Set that error on this field must be attached to the field instead of
324325
the parent field (the form in most cases).
325326

327+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
328+
326329
Inherited Options
327330
-----------------
328331

reference/forms/types/country.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ you should just use the ``choice`` type directly.
3333
| | - `multiple`_ |
3434
| | - `placeholder`_ |
3535
| | - `preferred_choices`_ |
36+
| | - `trim`_ |
3637
| | |
3738
| | from the :doc:`form </reference/forms/types/form>` type |
3839
| | |
@@ -80,6 +81,8 @@ type:
8081

8182
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8283

84+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
85+
8386
These options inherit from the :doc:`form </reference/forms/types/form>`
8487
type:
8588

reference/forms/types/currency.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ you should just use the ``choice`` type directly.
2626
| | - `multiple`_ |
2727
| | - `placeholder`_ |
2828
| | - `preferred_choices`_ |
29+
| | - `trim`_ |
2930
| | |
3031
| | from the :doc:`form </reference/forms/types/form>` type |
3132
| | |
@@ -70,6 +71,8 @@ type:
7071

7172
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
7273

74+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
75+
7376
These options inherit from the :doc:`form</reference/forms/types/form>`
7477
type:
7578

reference/forms/types/entity.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ objects from the database.
3232
| | - `placeholder`_ |
3333
| | - `preferred_choices`_ |
3434
| | - `translation_domain`_ |
35+
| | - `trim`_ |
3536
| | |
3637
| | from the :doc:`form </reference/forms/types/form>` type: |
3738
| | |
@@ -264,6 +265,8 @@ type:
264265

265266
.. include:: /reference/forms/types/options/choice_type_translation_domain.rst.inc
266267

268+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
269+
267270
These options inherit from the :doc:`form </reference/forms/types/form>`
268271
type:
269272

reference/forms/types/language.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ you should just use the ``choice`` type directly.
3535
| | - `multiple`_ |
3636
| | - `placeholder`_ |
3737
| | - `preferred_choices`_ |
38+
| | - `trim`_ |
3839
| | |
3940
| | from the :doc:`form </reference/forms/types/form>` type |
4041
| | |
@@ -82,6 +83,8 @@ type:
8283

8384
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8485

86+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
87+
8588
These options inherit from the :doc:`form </reference/forms/types/form>`
8689
type:
8790

reference/forms/types/locale.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ you should just use the ``choice`` type directly.
3636
| | - `multiple`_ |
3737
| | - `placeholder`_ |
3838
| | - `preferred_choices`_ |
39+
| | - `trim`_ |
3940
| | |
4041
| | from the :doc:`form </reference/forms/types/form>` type |
4142
| | |
@@ -83,6 +84,8 @@ type:
8384

8485
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
8586

87+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
88+
8689
These options inherit from the :doc:`form </reference/forms/types/form>`
8790
type:
8891

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trim
2+
~~~~
3+
4+
**type**: ``boolean`` **default**: ``false``
5+
6+
Trimming is disabled by default because the selected value or values must match
7+
the given choice values exactly (and they could contain whitespaces).

reference/forms/types/timezone.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ you should just use the ``choice`` type directly.
2727
| | - `multiple`_ |
2828
| | - `placeholder`_ |
2929
| | - `preferred_choices`_ |
30+
| | - `trim`_ |
3031
| | |
3132
| | from the :doc:`form </reference/forms/types/form>` type |
3233
| | |
@@ -72,6 +73,8 @@ type:
7273

7374
.. include:: /reference/forms/types/options/preferred_choices.rst.inc
7475

76+
.. include:: /reference/forms/types/options/choice_type_trim.rst.inc
77+
7578
These options inherit from the :doc:`form </reference/forms/types/form>`
7679
type:
7780

0 commit comments

Comments
 (0)