Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the errors of an individual field in Symfony2 twig template?

Normally, we can have the Symfony Form to output the field errors using the form_errors twig function, but how can we get the specific errors of an individual field, but not display it? Or is there any way that we can examine if one field has errors or not?

like image 450
imikay Avatar asked Mar 03 '12 13:03

imikay


1 Answers

You're looking for form.fieldname.vars.errors. If you want to check if a form field has errors or not, use the length filter.

like image 59
Maerlyn Avatar answered Nov 09 '22 11:11

Maerlyn