Skip to content

Instantly share code, notes, and snippets.

@JoshuaEstes
Last active December 18, 2015 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaEstes/5716798 to your computer and use it in GitHub Desktop.
Save JoshuaEstes/5716798 to your computer and use it in GitHub Desktop.
form.html.twig
{% set email_class = '' %}
{% if form.email.vars.errors %}
{% set email_class = 'error' %}
{% endif %}
{{ form_label(form.email, 'Email', {'label_attr':{'class':email_class}}) }}
{{ form_widget(form.email, {'attr':{'class':email_class}}) }}
{% if form.email.vars.errors %}
{% for error in form.email.vars.errors %}
<small class="error">{{ error.message }}</small>
{% endfor %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment