Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've got this in my form theme:

{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
        <ul>
            {% for error in errors %}
                <li>{{ error.message }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}

and when I call it like this:

form_errors(form)

It displays only 'global' errors for the form. How can I get in it all the form errors, even for specific fields in this one section?

share|improve this question

1 Answer 1

You can use

{{ form_errors(form.field) }}

to render errors of a specific field.

share|improve this answer
    
I know. But I don't want to remember about it every time I change the form. I want to display ALL the forms in one block. All the global ones and all the specific ones. –  user2394156 Jul 17 '13 at 10:25
    
do a loop {% for error in form_errors %} {{ error }} {% endfor %} –  Rpg600 Jul 17 '13 at 10:29
    
"Variable "form_errors" does not exist in..." –  user2394156 Jul 17 '13 at 10:56
    
sorry its {% for field in form %} {{ form_errors(field) }} {% endfor %} –  Rpg600 Jul 17 '13 at 11:10
    
I get the error mentioned above: "An exception has been thrown during the rendering of a template ("Unable to render the form as none of the following blocks exist: "_fos_user_registration_form_save_errors", "submit_errors", "button_errors".") in FOSUserBundle:Registration:register.html.twig at line 6. " –  user2394156 Jul 17 '13 at 11:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.