File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
reference/forms/types/options Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments