Simple check if form field has errors in Twig template

后端 未结 10 1659
一个人的身影
一个人的身影 2021-01-30 08:11

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:

10条回答
  •  悲哀的现实
    2021-01-30 08:57

    Since an empty array resolves to false, you can shorten your existing check to

    {% if form.WIDGET_NAME.get('errors') %}
    

提交回复
热议问题