Distinguish between bubbled errors and field errors in Symfony 2 form theme?

别来无恙 提交于 2019-12-12 01:37:15

问题


How can i distinguish between field errors and bubbled (form) errors? AFAIK the only block that controls this is:

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

I think i can't rely on errors|length: usually it's 1 for field errors, but can be 1 also for form errors :(


回答1:


To me it looks like by default you are unable to separate these errors. But you can extend the basic FormError class and add some property, which will define the exact place where error appeared.



来源:https://stackoverflow.com/questions/11677447/distinguish-between-bubbled-errors-and-field-errors-in-symfony-2-form-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!