From bbca3b0f08c84432ca8007df8787c29692d18e4d Mon Sep 17 00:00:00 2001 From: HeahDude Date: Sun, 15 Apr 2018 09:36:42 +0200 Subject: [PATCH 1/5] [Form] Fixed ChoiceType trim option --- reference/forms/types/choice.rst | 11 ++++++++++- reference/forms/types/country.rst | 1 + reference/forms/types/currency.rst | 1 + reference/forms/types/entity.rst | 1 + reference/forms/types/language.rst | 1 + reference/forms/types/locale.rst | 1 + reference/forms/types/timezone.rst | 1 + 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 69830ddf7c5..e23bf42843f 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -30,6 +30,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | Overridden | - `compound`_ | | options | - `empty_data`_ | | | - `error_bubbling`_ | +| | - `trim`_ | +-------------+------------------------------------------------------------------------------+ | Inherited | - `attr`_ | | options | - `by_reference`_ | @@ -106,7 +107,7 @@ method:: 'choice_attr' => function($category, $key, $index) { return ['class' => 'category_'.strtolower($category->getName())]; }, - + 'group_by' => function($category, $key, $index) { // randomly assign things into 2 groups return rand(0, 1) == 1 ? 'Group A' : 'Group B'; @@ -323,6 +324,14 @@ error_bubbling Set that error on this field must be attached to the field instead of the parent field (the form in most cases). +trim +~~~~ + +**type**: ``boolean`` **default**: ``false`` + +The trim is disabled by default for choices values. +The reason is that a value must match a set of predefined one. + Inherited Options ----------------- diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index 1c5ddd08c9b..daef58ad762 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -33,6 +33,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 4ca2fdf72aa..93102fbc9ff 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -26,6 +26,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 1087d2b3bcf..3cf9cf60f99 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -32,6 +32,7 @@ objects from the database. | | - `placeholder`_ | | | - `preferred_choices`_ | | | - `translation_domain`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type: | | | | diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 0156d101e09..3ebf9c99bda 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -35,6 +35,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 7a27e81ae41..bfaf940e972 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -36,6 +36,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index cf937bf80a8..f8354e552c9 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -27,6 +27,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | From 8bfa059275f4f5ffbb68c9970b907c43a02c2a09 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 18 Apr 2018 10:53:38 +0200 Subject: [PATCH 2/5] Reword --- reference/forms/types/choice.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index e23bf42843f..160783e240c 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -329,8 +329,8 @@ trim **type**: ``boolean`` **default**: ``false`` -The trim is disabled by default for choices values. -The reason is that a value must match a set of predefined one. +Trimming is disabled by default because the selected value or values must match +the given choice values exactly (and they could contain white spaces). Inherited Options ----------------- From 66316657e0ce01aeb3d4b28b63d9e5295f58f406 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Sun, 6 May 2018 23:11:11 +0200 Subject: [PATCH 3/5] fixup @xabbuh's comment proper choice type trim file --- reference/forms/types/choice.rst | 10 ++-------- reference/forms/types/country.rst | 4 +++- reference/forms/types/currency.rst | 4 +++- reference/forms/types/entity.rst | 4 +++- reference/forms/types/language.rst | 4 +++- reference/forms/types/locale.rst | 4 +++- reference/forms/types/options/choice_type_trim.rst.inc | 7 +++++++ reference/forms/types/timezone.rst | 4 +++- 8 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 reference/forms/types/options/choice_type_trim.rst.inc diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 160783e240c..d97751e7de8 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -30,7 +30,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | Overridden | - `compound`_ | | options | - `empty_data`_ | | | - `error_bubbling`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | +-------------+------------------------------------------------------------------------------+ | Inherited | - `attr`_ | | options | - `by_reference`_ | @@ -324,13 +324,7 @@ error_bubbling Set that error on this field must be attached to the field instead of the parent field (the form in most cases). -trim -~~~~ - -**type**: ``boolean`` **default**: ``false`` - -Trimming is disabled by default because the selected value or values must match -the given choice values exactly (and they could contain white spaces). +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc Inherited Options ----------------- diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index daef58ad762..42a92f505b5 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -33,7 +33,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type | | | | @@ -81,6 +81,8 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form ` type: diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 93102fbc9ff..b93c7c1471b 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -26,7 +26,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type | | | | @@ -71,6 +71,8 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form` type: diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 3cf9cf60f99..aead99851b4 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -32,7 +32,7 @@ objects from the database. | | - `placeholder`_ | | | - `preferred_choices`_ | | | - `translation_domain`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type: | | | | @@ -265,6 +265,8 @@ type: .. include:: /reference/forms/types/options/choice_type_translation_domain.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form ` type: diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 3ebf9c99bda..fd480147651 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -35,7 +35,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type | | | | @@ -83,6 +83,8 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form ` type: diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index bfaf940e972..f3bba3fa6b6 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -36,7 +36,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type | | | | @@ -84,6 +84,8 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form ` type: diff --git a/reference/forms/types/options/choice_type_trim.rst.inc b/reference/forms/types/options/choice_type_trim.rst.inc new file mode 100644 index 00000000000..371cbd7cddd --- /dev/null +++ b/reference/forms/types/options/choice_type_trim.rst.inc @@ -0,0 +1,7 @@ +trim +~~~~ + +**type**: ``boolean`` **default**: ``false`` + +Trimming is disabled by default because the selected value or values must match +the given choice values exactly (and they could contain white spaces). diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index f8354e552c9..598f22e66de 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -27,7 +27,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `trim`_ | +| | - `choice_type_trim`_ | | | | | | from the :doc:`form ` type | | | | @@ -73,6 +73,8 @@ type: .. include:: /reference/forms/types/options/preferred_choices.rst.inc +.. include:: /reference/forms/types/options/choice_type_trim.rst.inc + These options inherit from the :doc:`form ` type: From 360066d41196b5aedca49d443d941a94f76af221 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Mon, 7 May 2018 10:00:34 +0200 Subject: [PATCH 4/5] fixup option links --- reference/forms/types/choice.rst | 2 +- reference/forms/types/country.rst | 2 +- reference/forms/types/currency.rst | 2 +- reference/forms/types/entity.rst | 2 +- reference/forms/types/language.rst | 2 +- reference/forms/types/locale.rst | 2 +- reference/forms/types/timezone.rst | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index d97751e7de8..ba692cae826 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -30,7 +30,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | Overridden | - `compound`_ | | options | - `empty_data`_ | | | - `error_bubbling`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | +-------------+------------------------------------------------------------------------------+ | Inherited | - `attr`_ | | options | - `by_reference`_ | diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index 42a92f505b5..37c63782443 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -33,7 +33,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index b93c7c1471b..6715253edd7 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -26,7 +26,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index aead99851b4..70b5029ce42 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -32,7 +32,7 @@ objects from the database. | | - `placeholder`_ | | | - `preferred_choices`_ | | | - `translation_domain`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type: | | | | diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index fd480147651..d0bc7a637e5 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -35,7 +35,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index f3bba3fa6b6..2aae1712383 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -36,7 +36,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 598f22e66de..4d90b16661d 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -27,7 +27,7 @@ you should just use the ``choice`` type directly. | | - `multiple`_ | | | - `placeholder`_ | | | - `preferred_choices`_ | -| | - `choice_type_trim`_ | +| | - `trim`_ | | | | | | from the :doc:`form ` type | | | | From 2dd6c56e8baa57c61f8ac81dce00612ef6a23aa3 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Mon, 7 May 2018 21:26:35 +0200 Subject: [PATCH 5/5] fixup typo --- reference/forms/types/options/choice_type_trim.rst.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/forms/types/options/choice_type_trim.rst.inc b/reference/forms/types/options/choice_type_trim.rst.inc index 371cbd7cddd..999a33ef6bc 100644 --- a/reference/forms/types/options/choice_type_trim.rst.inc +++ b/reference/forms/types/options/choice_type_trim.rst.inc @@ -4,4 +4,4 @@ trim **type**: ``boolean`` **default**: ``false`` Trimming is disabled by default because the selected value or values must match -the given choice values exactly (and they could contain white spaces). +the given choice values exactly (and they could contain whitespaces).