Simple check if form field has errors in Twig template

后端 未结 10 1637
一个人的身影
一个人的身影 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:58

    I had a similar problem, but form.points doesn't exist in my twig templates.

    I had to get the number of errors in the controller, then pass it into my templates as a variable. $form->getErrors() does not behave as you might expect in your controller though. See this SO question for a function that will get the form errors correctly.

提交回复
热议问题