Search code examples
symfonytwigsymfony-forms

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.


Solution

  • That method does not exist. I typically do {% if form.points.vars.errors|length %}.