Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add error_mapping form option documentation#2694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
weaverryan merged 5 commits intosymfony:2.1fromdocteurklein:patch-2
Jun 22, 2013
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsreference/forms/types/checkbox.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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</reference/forms/types/form>` |
Expand DownExpand Up@@ -61,4 +62,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
3 changes: 3 additions & 0 deletionsreference/forms/types/choice.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ option.
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `mapped`_ |
| | - `virtual`_ |
| | - `by_reference`_ |
Expand DownExpand Up@@ -121,6 +122,8 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/collection.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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`_ |
Expand DownExpand Up@@ -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
~~~~~~~~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/country.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ you should just use the ``choice`` type directly.
| | - `preferred_choices`_ |
| | - `empty_value`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `required`_ |
| | - `label`_ |
| | - `read_only`_ |
Expand DownExpand Up@@ -68,6 +69,8 @@ These options inherit from the :doc:`choice</reference/forms/types/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</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/required.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/date.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 |
+----------------------+-----------------------------------------------------------------------------+
Expand DownExpand Up@@ -148,3 +149,5 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
5 changes: 4 additions & 1 deletionreference/forms/types/email.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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</reference/forms/types/form>` |
Expand All@@ -43,4 +44,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/error_bubbling.rst.inc

.. include:: /reference/forms/types/options/mapped.rst.inc
.. include:: /reference/forms/types/options/error_mapping.rst.inc

.. include:: /reference/forms/types/options/mapped.rst.inc
3 changes: 3 additions & 0 deletionsreference/forms/types/entity.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ objects from the database.
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `mapped`_ |
+-------------+------------------------------------------------------------------+
| Parent type | :doc:`choice</reference/forms/types/choice>` |
Expand DownExpand Up@@ -173,4 +174,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
3 changes: 3 additions & 0 deletionsreference/forms/types/file.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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</reference/forms/types/form>` |
Expand DownExpand Up@@ -95,4 +96,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
3 changes: 3 additions & 0 deletionsreference/forms/types/hidden.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ The hidden type represents a hidden input field.
| Inherited | - `data`_ |
| options | - `property_path`_ |
| | - `mapped`_ |
| | - `error_mapping`_ |
+-------------+----------------------------------------------------------------------+
| Parent type | :doc:`field</reference/forms/types/form>` |
+-------------+----------------------------------------------------------------------+
Expand DownExpand Up@@ -48,3 +49,5 @@ These options inherit from the :doc:`date</reference/forms/types/form>` 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
3 changes: 3 additions & 0 deletionsreference/forms/types/integer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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`_ |
Expand DownExpand Up@@ -73,6 +74,8 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/language.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ you should just use the ``choice`` type directly.
| | - `preferred_choices`_ |
| | - `empty_value`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `required`_ |
| | - `label`_ |
| | - `read_only`_ |
Expand DownExpand Up@@ -69,6 +70,8 @@ These options inherit from the :doc:`choice</reference/forms/types/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</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/required.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/locale.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,7 @@ you should just use the ``choice`` type directly.
| | - `preferred_choices`_ |
| | - `empty_value`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `required`_ |
| | - `label`_ |
| | - `read_only`_ |
Expand DownExpand Up@@ -71,6 +72,8 @@ These options inherit from the :doc:`choice</reference/forms/types/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</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/required.rst.inc
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/money.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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`_ |
Expand DownExpand Up@@ -94,6 +95,8 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/number.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ you want to use for your number.
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `invalid_message`_ |
| | - `invalid_message_parameters`_ |
| | - `mapped`_ |
Expand DownExpand Up@@ -92,6 +93,8 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
Expand Down
33 changes: 33 additions & 0 deletionsreference/forms/types/options/error_mapping.rst.inc
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
.. versionadded:: 2.1
The ``error_mapping`` option is new to Symfony 2.1.

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 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 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.
5 changes: 4 additions & 1 deletionreference/forms/types/password.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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</reference/forms/types/text>` |
Expand DownExpand Up@@ -59,4 +60,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` type:

.. include:: /reference/forms/types/options/error_bubbling.rst.inc

.. include:: /reference/forms/types/options/mapped.rst.inc
.. include:: /reference/forms/types/options/error_mapping.rst.inc

.. include:: /reference/forms/types/options/mapped.rst.inc
3 changes: 3 additions & 0 deletionsreference/forms/types/percent.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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`_ |
Expand DownExpand Up@@ -78,6 +79,8 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
Expand Down
3 changes: 3 additions & 0 deletionsreference/forms/types/radio.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@ If you want to have a Boolean field, use :doc:`checkbox</reference/forms/types/c
| | - `read_only`_ |
| | - `disabled`_ |
| | - `error_bubbling`_ |
| | - `error_mapping`_ |
| | - `mapped`_ |
+-------------+---------------------------------------------------------------------+
| Parent type | :doc:`field</reference/forms/types/form>` |
Expand DownExpand Up@@ -55,4 +56,6 @@ These options inherit from the :doc:`field</reference/forms/types/form>` 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
3 changes: 3 additions & 0 deletionsreference/forms/types/repeated.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ accuracy.
| Inherited | - `invalid_message`_ |
| options | - `invalid_message_parameters`_ |
| | - `mapped`_ |
| | - `error_mapping`_ |
+-------------+------------------------------------------------------------------------+
| Parent type | :doc:`field</reference/forms/types/form>` |
+-------------+------------------------------------------------------------------------+
Expand DownExpand Up@@ -189,3 +190,5 @@ These options inherit from the :doc:`date</reference/forms/types/form>` 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
Loading

[8]ページ先頭

©2009-2025 Movatter.jp