@@ -8,8 +8,8 @@ groups will be used by the validator.
8
8
9
9
For ``null`` the validator will just use the ``Default`` group.
10
10
11
- If you specify the groups as array or string they will used by the validator
12
- as they are::
11
+ If you specify the groups as an array or string they will be used by the
12
+ validator as they are::
13
13
14
14
public function configureOptions(OptionsResolver $resolver)
15
15
{
@@ -22,7 +22,7 @@ This is equivalent to passing the group as array::
22
22
23
23
'validation_groups' => array('Registration'),
24
24
25
- The form' s data will be :doc:`validated agains all groups </form/validation_groups>`.
25
+ The form's data will be :doc:`validated against all given groups </form/validation_groups>`.
26
26
27
27
If the validation groups depend on the form's data a callable may be passed to
28
28
the option. Symfony will then pass the form when calling it::
@@ -36,21 +36,12 @@ the option. Symfony will then pass the form when calling it::
36
36
$resolver->setDefaults(array(
37
37
'validation_groups' => function (FormInterface $form) {
38
38
$entity = $form->getData();
39
- return $entity- > getValidationGroups ();
39
+
40
+ return $entity->isUser() ? array('User') : array('Company');
40
41
},
41
42
));
42
43
}
43
44
44
- The class that the form is used for may look like this ::
45
-
46
- class Account
47
- {
48
- public function getValidationGroups ()
49
- {
50
- return $this - > isUser () ? array (' User' ) : array (' Company' );
51
- }
52
- }
53
-
54
45
.. seealso::
55
46
56
47
You can read more about this in :doc:`/form/data_based_validation`.
@@ -64,7 +55,7 @@ The class that the form is used for may look like this::
64
55
If you need advanced logic to determine the validation groups have
65
56
a look at :doc:`/form/validation_group_service_resolver`.
66
57
67
- In some cases, you want to validate your groups by steps . To do this , you
58
+ In some cases, you want to validate your groups step by step . To do this, you
68
59
can pass a :class:`Symfony\\Component\\Validator\\Constraints\\GroupSequence`
69
60
to this option. This enables you to validate against multiple groups,
70
61
like when you pass multiple groups in an array, but with the difference that
0 commit comments