From 267105f515a377a03e5fa0422f35602f78ad7f86 Mon Sep 17 00:00:00 2001 From: Florian Klein Date: Tue, 4 Jun 2013 16:22:48 +0300 Subject: [PATCH 1/5] Create error_mapping.rst.inc | Q | A | ------------- | --- | Doc fix? | yes | New docs? | yes | Applies to | 2.1+ | Fixed tickets | ~ see http://symfony.com/blog/form-goodness-in-symfony-2-1#error-mapping-fu --- .../forms/types/options/error_mapping.rst.inc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 reference/forms/types/options/error_mapping.rst.inc diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc new file mode 100644 index 00000000000..2bed0490a43 --- /dev/null +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -0,0 +1,23 @@ +error_mapping +~~~~~~~~~~~~~ + +**type**: ``array`` **default**: ``empty`` + +This option permits to modify the default target of errors. + +Imagine a custom method named ``matchingCityAndZipCode`` validates whether the city and zip code matches. +Unfortunately, there is no "matchingCityAndZipCode" field in your form, +so all that Symfony can do for you is display the error on top of the form. + +With customized error mapping, you can do better: make the error be mapped to the city field. + +Here are to understand the left and the right side of the mapping: + + * The left side contains property paths. + * If the violation is generated on a property or method of a class, its path is simply propertyName. + * If the violation is generated on an entry of an array or ArrayAccess object, the property path is [indexName]. + * You can construct nested property paths by concatenating them, separating properties by dots, + * for example: addresses[work].matchingCityAndZipCode + *The right side contains simply the names of fields in the form. + * The left side of the error mapping also accepts a dot ., which refers to the field itself. + That means that any error added to the field is added to the given nested field instead. From 54f0d44d0bd2faae4fd90bb938e9f78907a5e2f5 Mon Sep 17 00:00:00 2001 From: Klein Florian Date: Wed, 12 Jun 2013 17:54:59 +0200 Subject: [PATCH 2/5] include references to error_mapping in field inheritance --- reference/forms/types/checkbox.rst | 3 +++ reference/forms/types/choice.rst | 3 +++ reference/forms/types/collection.rst | 3 +++ reference/forms/types/country.rst | 3 +++ reference/forms/types/date.rst | 3 +++ reference/forms/types/email.rst | 5 ++++- reference/forms/types/entity.rst | 3 +++ reference/forms/types/file.rst | 3 +++ reference/forms/types/hidden.rst | 3 +++ reference/forms/types/integer.rst | 3 +++ reference/forms/types/language.rst | 3 +++ reference/forms/types/locale.rst | 3 +++ reference/forms/types/money.rst | 3 +++ reference/forms/types/number.rst | 3 +++ reference/forms/types/password.rst | 5 ++++- reference/forms/types/percent.rst | 3 +++ reference/forms/types/radio.rst | 3 +++ reference/forms/types/repeated.rst | 3 +++ reference/forms/types/search.rst | 3 +++ reference/forms/types/text.rst | 3 +++ reference/forms/types/textarea.rst | 3 +++ reference/forms/types/time.rst | 3 +++ reference/forms/types/timezone.rst | 3 +++ reference/forms/types/url.rst | 3 +++ 24 files changed, 74 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index 541886bbc42..8611d80d66a 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -18,6 +18,7 @@ if the box is unchecked, the value will be set to false. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | @@ -61,4 +62,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index ad0d611c29f..fcd2d30135c 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -25,6 +25,7 @@ option. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | | | - `virtual`_ | | | - `by_reference`_ | @@ -121,6 +122,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc .. include:: /reference/forms/types/options/virtual.rst.inc diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 10952ded3c4..2ec87e2fa48 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -22,6 +22,7 @@ forms, which is useful when creating forms that expose one-to-many relationships +-------------+-----------------------------------------------------------------------------+ | Inherited | - `label`_ | | options | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `by_reference`_ | | | - `empty_data`_ | | | - `mapped`_ | @@ -345,6 +346,8 @@ Not all options are listed here - only the most applicable to this type: .. include:: /reference/forms/types/options/mapped.rst.inc +.. include:: /reference/forms/types/options/_error_mapping.rst.inc + error_bubbling ~~~~~~~~~~~~~~ diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index ccc5a739666..7e026a0c4fe 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -30,6 +30,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | @@ -68,6 +69,8 @@ These options inherit from the :doc:`choice` type .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + These options inherit from the :doc:`date` type: .. include:: /reference/forms/types/options/required.rst.inc diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index c1719b1c5ac..e5ce82da8c2 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -38,6 +38,7 @@ day, and year) or three select boxes (see the `widget_` option). | | - `disabled`_ | | | - `mapped`_ | | | - `virtual`_ | +| | - `error_mapping`_ | +----------------------+-----------------------------------------------------------------------------+ | Parent type | ``field`` (if text), ``form`` otherwise | +----------------------+-----------------------------------------------------------------------------+ @@ -148,3 +149,5 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/mapped.rst.inc .. include:: /reference/forms/types/options/virtual.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index 56a406da1bc..28c5c7f02e3 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -17,6 +17,7 @@ The ``email`` field is a text field that is rendered using the HTML5 | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+---------------------------------------------------------------------+ | Parent type | :doc:`field` | @@ -43,4 +44,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc -.. include:: /reference/forms/types/options/mapped.rst.inc \ No newline at end of file +.. include:: /reference/forms/types/options/error_mapping.rst.inc + +.. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 226bcddd44f..1788ecd4707 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -30,6 +30,7 @@ objects from the database. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------+ | Parent type | :doc:`choice` | @@ -173,4 +174,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index e31714d7b95..e08a92eb568 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -14,6 +14,7 @@ The ``file`` type represents a file input in your form. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+---------------------------------------------------------------------+ | Parent type | :doc:`form` | @@ -95,4 +96,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index 3ab10c1db02..324f34994c1 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -15,6 +15,7 @@ The hidden type represents a hidden input field. | Inherited | - `data`_ | | options | - `property_path`_ | | | - `mapped`_ | +| | - `error_mapping`_ | +-------------+----------------------------------------------------------------------+ | Parent type | :doc:`field` | +-------------+----------------------------------------------------------------------+ @@ -48,3 +49,5 @@ These options inherit from the :doc:`date` type: .. include:: /reference/forms/types/options/property_path.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index a9f83e232c6..7ab159f98be 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -23,6 +23,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down (e.g. 6 | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | @@ -73,6 +74,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/invalid_message.rst.inc .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index d5e7397da85..8239b8c74ee 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -31,6 +31,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | @@ -69,6 +70,8 @@ These options inherit from the :doc:`choice` type .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + These options inherit from the :doc:`date` type: .. include:: /reference/forms/types/options/required.rst.inc diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 7658f7ad4c4..eee5e3af7f1 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -32,6 +32,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | @@ -71,6 +72,8 @@ These options inherit from the :doc:`choice` type .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + These options inherit from the :doc:`date` type: .. include:: /reference/forms/types/options/required.rst.inc diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 285ffa577d1..0c7d832c01a 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -24,6 +24,7 @@ how the input and output of the data is handled. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | @@ -94,6 +95,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/invalid_message.rst.inc .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 6d9ae5587aa..837aec67c12 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -20,6 +20,7 @@ you want to use for your number. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | @@ -92,6 +93,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/invalid_message.rst.inc .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index b067bee64e1..04108033c4e 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -18,6 +18,7 @@ The ``password`` field renders an input password text box. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`text` | @@ -59,4 +60,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc -.. include:: /reference/forms/types/options/mapped.rst.inc \ No newline at end of file +.. include:: /reference/forms/types/options/error_mapping.rst.inc + +.. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 52fe448a495..f82ffa68db1 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -23,6 +23,7 @@ This field adds a percentage sign "``%``" after the input box. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | @@ -78,6 +79,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/invalid_message.rst.inc .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index 51906275cee..fb59cb5d0c8 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -22,6 +22,7 @@ If you want to have a Boolean field, use :doc:`checkbox` | @@ -55,4 +56,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index 32b25ee1365..c1f5e0ca58f 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -25,6 +25,7 @@ accuracy. | Inherited | - `invalid_message`_ | | options | - `invalid_message_parameters`_ | | | - `mapped`_ | +| | - `error_mapping`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | +-------------+------------------------------------------------------------------------+ @@ -189,3 +190,5 @@ These options inherit from the :doc:`date` type: .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index f07e886ef90..e3067aafa81 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -19,6 +19,7 @@ Read about the input search field at `DiveIntoHTML5.info`_ | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+----------------------------------------------------------------------+ | Parent type | :doc:`text` | @@ -45,6 +46,8 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc .. _`DiveIntoHTML5.info`: http://diveintohtml5.info/forms.html#type-search diff --git a/reference/forms/types/text.rst b/reference/forms/types/text.rst index f5a309c5256..51652bada0a 100644 --- a/reference/forms/types/text.rst +++ b/reference/forms/types/text.rst @@ -16,6 +16,7 @@ The text field represents the most basic input text field. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+--------------------------------------------------------------------+ | Parent type | :doc:`field` | @@ -43,4 +44,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index 457c4332cdc..28c38a1d482 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -16,6 +16,7 @@ Renders a ``textarea`` HTML element. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | @@ -42,4 +43,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index fb3c92beb32..73ae06424fc 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -33,6 +33,7 @@ as a ``DateTime`` object, a string, a timestamp or an array. | | - `disabled`_ | | | - `mapped`_ | | | - `virtual`_ | +| | - `error_mapping`_ | +----------------------+-----------------------------------------------------------------------------+ | Parent type | form | +----------------------+-----------------------------------------------------------------------------+ @@ -146,3 +147,5 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/mapped.rst.inc .. include:: /reference/forms/types/options/virtual.rst.inc + +.. include:: /reference/forms/types/options/error_mapping.rst.inc diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index b1c3359e1ca..663df8c7c07 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -30,6 +30,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`choice` | @@ -73,4 +74,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index aefc048f47c..666e5c5830b 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -20,6 +20,7 @@ have a protocol. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+-------------------------------------------------------------------+ | Parent type | :doc:`text` | @@ -58,4 +59,6 @@ These options inherit from the :doc:`field` type: .. include:: /reference/forms/types/options/error_bubbling.rst.inc +.. include:: /reference/forms/types/options/error_mapping.rst.inc + .. include:: /reference/forms/types/options/mapped.rst.inc From 61f8403c994c2ba1d6ec30739973e8452157b353 Mon Sep 17 00:00:00 2001 From: Klein Florian Date: Thu, 13 Jun 2013 11:20:53 +0200 Subject: [PATCH 3/5] align table pipes --- reference/forms/types/checkbox.rst | 2 +- reference/forms/types/choice.rst | 2 +- reference/forms/types/collection.rst | 2 +- reference/forms/types/country.rst | 2 +- reference/forms/types/date.rst | 2 +- reference/forms/types/email.rst | 2 +- reference/forms/types/entity.rst | 2 +- reference/forms/types/file.rst | 2 +- reference/forms/types/hidden.rst | 2 +- reference/forms/types/integer.rst | 2 +- reference/forms/types/language.rst | 2 +- reference/forms/types/locale.rst | 2 +- reference/forms/types/money.rst | 2 +- reference/forms/types/number.rst | 2 +- reference/forms/types/password.rst | 2 +- reference/forms/types/percent.rst | 2 +- reference/forms/types/radio.rst | 2 +- reference/forms/types/repeated.rst | 2 +- reference/forms/types/search.rst | 2 +- reference/forms/types/text.rst | 2 +- reference/forms/types/textarea.rst | 2 +- reference/forms/types/time.rst | 2 +- reference/forms/types/timezone.rst | 2 +- reference/forms/types/url.rst | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index 8611d80d66a..e72400d2684 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -18,7 +18,7 @@ if the box is unchecked, the value will be set to false. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index fcd2d30135c..8c9c924f862 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -25,7 +25,7 @@ option. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | | | - `virtual`_ | | | - `by_reference`_ | diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 2ec87e2fa48..01f0f46db0b 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -22,7 +22,7 @@ forms, which is useful when creating forms that expose one-to-many relationships +-------------+-----------------------------------------------------------------------------+ | Inherited | - `label`_ | | options | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `by_reference`_ | | | - `empty_data`_ | | | - `mapped`_ | diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index 7e026a0c4fe..f26700d26c2 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -30,7 +30,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index e5ce82da8c2..aa87d713de2 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -38,7 +38,7 @@ day, and year) or three select boxes (see the `widget_` option). | | - `disabled`_ | | | - `mapped`_ | | | - `virtual`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | +----------------------+-----------------------------------------------------------------------------+ | Parent type | ``field`` (if text), ``form`` otherwise | +----------------------+-----------------------------------------------------------------------------+ diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index 28c5c7f02e3..94d586886ee 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -17,7 +17,7 @@ The ``email`` field is a text field that is rendered using the HTML5 | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+---------------------------------------------------------------------+ | Parent type | :doc:`field` | diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 1788ecd4707..c47382d74c6 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -30,7 +30,7 @@ objects from the database. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------+ | Parent type | :doc:`choice` | diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index e08a92eb568..f9ff36d3950 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -14,7 +14,7 @@ The ``file`` type represents a file input in your form. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+---------------------------------------------------------------------+ | Parent type | :doc:`form` | diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index 324f34994c1..a0e954c3bfe 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -15,7 +15,7 @@ The hidden type represents a hidden input field. | Inherited | - `data`_ | | options | - `property_path`_ | | | - `mapped`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | +-------------+----------------------------------------------------------------------+ | Parent type | :doc:`field` | +-------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 7ab159f98be..00bd559e67e 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -23,7 +23,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down (e.g. 6 | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 8239b8c74ee..6f606541d06 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -31,7 +31,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index eee5e3af7f1..013ca4b6ec0 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -32,7 +32,7 @@ you should just use the ``choice`` type directly. | | - `preferred_choices`_ | | | - `empty_value`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `required`_ | | | - `label`_ | | | - `read_only`_ | diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 0c7d832c01a..df489534fa4 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -24,7 +24,7 @@ how the input and output of the data is handled. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 837aec67c12..1dd5234c38b 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -20,7 +20,7 @@ you want to use for your number. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 04108033c4e..8ae6fee67df 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -18,7 +18,7 @@ The ``password`` field renders an input password text box. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`text` | diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index f82ffa68db1..33e566fbf5f 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -23,7 +23,7 @@ This field adds a percentage sign "``%``" after the input box. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `invalid_message`_ | | | - `invalid_message_parameters`_ | | | - `mapped`_ | diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index fb59cb5d0c8..f2fa999e97a 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -22,7 +22,7 @@ If you want to have a Boolean field, use :doc:`checkbox` | diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index c1f5e0ca58f..6f0cc85fe5d 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -25,7 +25,7 @@ accuracy. | Inherited | - `invalid_message`_ | | options | - `invalid_message_parameters`_ | | | - `mapped`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | +-------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index e3067aafa81..463e8cbf600 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -19,7 +19,7 @@ Read about the input search field at `DiveIntoHTML5.info`_ | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+----------------------------------------------------------------------+ | Parent type | :doc:`text` | diff --git a/reference/forms/types/text.rst b/reference/forms/types/text.rst index 51652bada0a..2dd4e1479c3 100644 --- a/reference/forms/types/text.rst +++ b/reference/forms/types/text.rst @@ -16,7 +16,7 @@ The text field represents the most basic input text field. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+--------------------------------------------------------------------+ | Parent type | :doc:`field` | diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index 28c38a1d482..2c6f6b6c632 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -16,7 +16,7 @@ Renders a ``textarea`` HTML element. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`field` | diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 73ae06424fc..303a9c29061 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -33,7 +33,7 @@ as a ``DateTime`` object, a string, a timestamp or an array. | | - `disabled`_ | | | - `mapped`_ | | | - `virtual`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | +----------------------+-----------------------------------------------------------------------------+ | Parent type | form | +----------------------+-----------------------------------------------------------------------------+ diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 663df8c7c07..535a552f75e 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -30,7 +30,7 @@ you should just use the ``choice`` type directly. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+------------------------------------------------------------------------+ | Parent type | :doc:`choice` | diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index 666e5c5830b..ce25cb82fe3 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -20,7 +20,7 @@ have a protocol. | | - `read_only`_ | | | - `disabled`_ | | | - `error_bubbling`_ | -| | - `error_mapping`_ | +| | - `error_mapping`_ | | | - `mapped`_ | +-------------+-------------------------------------------------------------------+ | Parent type | :doc:`text` | From b634bbcb62fe31c81f95c7d1e53fc7a566d8d41f Mon Sep 17 00:00:00 2001 From: Klein Florian Date: Thu, 13 Jun 2013 11:31:27 +0200 Subject: [PATCH 4/5] wrap lines --- .../forms/types/options/error_mapping.rst.inc | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc index 2bed0490a43..6a19b151ab6 100644 --- a/reference/forms/types/options/error_mapping.rst.inc +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -5,19 +5,29 @@ error_mapping This option permits to modify the default target of errors. -Imagine a custom method named ``matchingCityAndZipCode`` validates whether the city and zip code matches. +Imagine a custom method named ``matchingCityAndZipCode`` validates +whether the city and zip code matches. Unfortunately, there is no "matchingCityAndZipCode" field in your form, so all that Symfony can do for you is display the error on top of the form. -With customized error mapping, you can do better: make the error be mapped to the city field. +With customized error mapping, you can do better: +make the error be mapped to the city field. -Here are to understand the left and the right side of the mapping: +Here are the rules to understand the left and the right side of the mapping: * The left side contains property paths. - * If the violation is generated on a property or method of a class, its path is simply propertyName. - * If the violation is generated on an entry of an array or ArrayAccess object, the property path is [indexName]. - * You can construct nested property paths by concatenating them, separating properties by dots, - * for example: addresses[work].matchingCityAndZipCode - *The right side contains simply the names of fields in the form. - * The left side of the error mapping also accepts a dot ., which refers to the field itself. - That means that any error added to the field is added to the given nested field instead. + * If the violation is generated on a property or method of a class, + its path is simply propertyName. + * If the violation is generated on an entry of an ``array`` + or ``ArrayAccess`` object, the property path is ``[indexName]``. + * You can construct nested property paths by concatenating them, + separating properties by dots, + * for example: ``addresses[work].matchingCityAndZipCode`` + * The left side of the error mapping also accepts a dot ``.``, + which refers to the field itself. + That means that any error added to the field is added to the given + nested field instead. + * The right side contains simply the names of fields in the form. + +.. versionadded:: 2.1 + The ``error_mapping`` option is new to Symfony 2.1. From fe31fd2b9239cc3f1b2532f8ccab912c982529a3 Mon Sep 17 00:00:00 2001 From: Florian Klein Date: Thu, 13 Jun 2013 16:08:25 +0200 Subject: [PATCH 5/5] move versionadded to top of the file --- reference/forms/types/options/error_mapping.rst.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc index 6a19b151ab6..22f395029b0 100644 --- a/reference/forms/types/options/error_mapping.rst.inc +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -1,3 +1,6 @@ +.. versionadded:: 2.1 + The ``error_mapping`` option is new to Symfony 2.1. + error_mapping ~~~~~~~~~~~~~ @@ -28,6 +31,3 @@ Here are the rules to understand the left and the right side of the mapping: That means that any error added to the field is added to the given nested field instead. * The right side contains simply the names of fields in the form. - -.. versionadded:: 2.1 - The ``error_mapping`` option is new to Symfony 2.1.