8000 Update forms.rst · githubfromgui/symfony-docs@4e6fd23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e6fd23

Browse files
authored
Update forms.rst
increase emphasis on the two ways (approaches) of adding constraints in Symfony
1 parent 811df86 commit 4e6fd23

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

forms.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,15 @@ Before using validation, add support for it in your application:
459459
460460
$ composer require symfony/validator
461461
462-
Validation is done by adding a set of rules (called constraints) to a class. To
463-
see this in action, add validation constraints so that the ``task`` field cannot
464-
be empty and the ``dueDate`` field cannot be empty and must be a valid \DateTime
462+
Validation is done by adding a set of rules, called (validation) constraints,
463+
to a class.
464+
465+
There are two approaches - you can either add the constraints to the entity,
466+
or you can add the constraints to the form.
467+
468+
To see the first approach - adding constraints to the entity - in action,
469+
add the validation constraints, so that the ``task`` field cannot be empty,
470+
and the ``dueDate`` field cannot be empty, and must be a valid \DateTime
465471
object.
466472

467473
.. configuration-block::
@@ -544,9 +550,11 @@ object.
544550
}
545551
546552
That's it! If you re-submit the form with invalid data, you'll see the
547-
corresponding errors printed out with the form. Read the
548-
:doc:`Symfony validation documentation </validation>` to learn more about this
549-
powerful feature.
553+
corresponding errors printed out with the form.
554+
555+
To see the second approach - adding constraints to the form and to
556+
learn more about the validation constraints, please refer to the
557+
:doc:`Symfony validation documentation </validation>`.
550558

551559
Other Common Form Features
552560
--------------------------

0 commit comments

Comments
 (0)
0