We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70d6ce0 commit 21c4c9fCopy full SHA for 21c4c9f
best_practices/forms.rst
@@ -145,6 +145,27 @@ view layer:
145
class="btn btn-default pull-right" />
146
{{ form_end(form) }}
147
148
+Validation
149
+----------
150
+
151
+Define your validation constraints outside of the forms, for instance directly on the object
152
+class used as data mapper::
153
154
+ // src/Entity/Post.php
155
156
+ // ...
157
+ use Symfony\Component\Validator\Constraints as Assert;
158
159
+ class Post
160
+ {
161
+ /**
162
+ * @Assert\NotBlank()
163
+ */
164
+ public $title;
165
+ }
166
167
+This make them reusables and independents from the validation rules.
168
169
Rendering the Form
170
------------------
171
0 commit comments