Skip to content

Instantly share code, notes, and snippets.

@smottt
Created January 16, 2012 15:12
Show Gist options
  • Save smottt/1621293 to your computer and use it in GitHub Desktop.
Save smottt/1621293 to your computer and use it in GitHub Desktop.
Check if symfony2 form has errors in a twig template
{% if form.get('errors') is not empty %}
Magic errors display!
{% endif %}
@developeryashraj
Copy link

Check if any particular field has error in a twig template

{% if form.email.vars.errors|length > 0 %}
      Do some work!!
{% endif %}

@midnai
Copy link

midnai commented Oct 9, 2014

Thank You!

@phillipsnick
Copy link

I have been faffing around for a good half an hour trying to get this working, couldn't get the above examples working. The following works for me though.

{% if form.domain.vars.errors.count() > 0 %}
  Do something
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment