Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple check if form field has errors in Twig template

In Twig template I check if a field has an error like this:

{% if form.points.get('errors') is not empty %} 

Is there any method like:

{% if form.points.hasErrors() %} 

to do it simpler? It's not a big difference, but if I can't do it easier why not.

like image 539
Dawid Ohia Avatar asked Jan 18 '12 17:01

Dawid Ohia


1 Answers

better way I found, is to use this kind of code

{% if not form.vars.valid %} <div class="alert alert-error">     {{ form_errors(form) }} </div> {% endif %} 
like image 88
birko Avatar answered Oct 12 '22 22:10

birko