Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class constraint validator in form type class?

In the documentation it lists examples for applying a class validation constraint to Annotations, XML and YAML but not for PHP.

Since the validation is not applied to a property, where do I add this class validation constraint to the whole class inside a Symfony form type?

like image 272
Tek Avatar asked Mar 23 '17 16:03

Tek


1 Answers

I think I've found a solution here: https://knpuniversity.com/screencast/question-answer-day/custom-validation-property-path There is a tip what says:

If your form lives in a form type class, simply add the constraints key to the setDefaulOptions method.

like image 57
xsubira Avatar answered Nov 19 '22 11:11

xsubira