templates/form_validation.html.twig line 1

  1. {# As the user only needs to be notified once to scroll down to check the form fields, no need for displaying multiple 
  2. warning messages at the top of the page. So, we will either display the form scope validation message if it it contains
  3. an error, otherwise display a wanring that one or more fields has invalid input #}
  4. {% if form_errors(current_form) is not empty %}
  5.     {# display form global validation messages #}
  6.     <div class="alert alert-danger" role="alert">
  7.         {{ form_errors(current_form) }}
  8.     </div>
  9. {% else %}
  10.     {# Show a warning if any form field has invalid input #}
  11.     {# check if any form field has an error, then break after finding the first error as a single error is enough to show the warning #}
  12.     {% if current_form.vars.valid == false %}
  13.         <div class="alert alert-danger" role="alert">
  14.             {{ "some form fields have errors" | trans({}, 'validators') }}
  15.         </div>
  16.     {% endif %}
  17. {% endif %}