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

Appearance settings

Commit 267105f

Browse filesBrowse files
committed
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
1 parent 3081634 commit 267105f
Copy full SHA for 267105f

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error_mapping
2+
~~~~~~~~~~~~~
3+
4+
**type**: ``array`` **default**: ``empty``
5+
6+
This option permits to modify the default target of errors.
7+
8+
Imagine a custom method named ``matchingCityAndZipCode`` validates whether the city and zip code matches.
9+
Unfortunately, there is no "matchingCityAndZipCode" field in your form,
10+
so all that Symfony can do for you is display the error on top of the form.
11+
12+
With customized error mapping, you can do better: make the error be mapped to the city field.
13+
14+
Here are to understand the left and the right side of the mapping:
15+
16+
* The left side contains property paths.
17+
* If the violation is generated on a property or method of a class, its path is simply propertyName.
18+
* If the violation is generated on an entry of an array or ArrayAccess object, the property path is [indexName].
19+
* You can construct nested property paths by concatenating them, separating properties by dots,
20+
* for example: addresses[work].matchingCityAndZipCode
21+
*The right side contains simply the names of fields in the form.
22+
* The left side of the error mapping also accepts a dot ., which refers to the field itself.
23+
That means that any error added to the field is added to the given nested field instead.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.