templates/default/_flash_messages.html.twig line 1

Open in your IDE?
  1. {#
  2.    This is a template fragment designed to be included in other templates
  3.    See https://symfony.com/doc/current/templates.html#including-templates
  4.    A common practice to better distinguish between templates and fragments is to
  5.    prefix fragments with an underscore. That's why this template is called
  6.    '_flash_messages.html.twig' instead of 'flash_messages.html.twig'
  7. #}
  8. {#
  9.    The check is needed to prevent starting the session when looking for "flash messages":
  10.    https://symfony.com/doc/current/session.html#avoid-starting-sessions-for-anonymous-users
  11.    TIP: With FOSHttpCache you can also adapt this to make it cache safe:
  12.    https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
  13. #}
  14. {% if app.request.hasPreviousSession %}
  15.     <div class="messages">
  16.         {% for type, messages in app.flashes %}
  17.             {% for message in messages %}
  18.                 {# Bootstrap alert, see https://getbootstrap.com/docs/3.4/components/#alerts #}
  19.                 <div class="alert alert-dismissible alert-{{ type }} fade in" role="alert">
  20.                     <button type="button" class="close" data-dismiss="alert" aria-label="{{ 'action.close'|trans }}">
  21.                         <span aria-hidden="true">&times;</span>
  22.                     </button>
  23.                     {{ message|trans }}
  24.                 </div>
  25.             {% endfor %}
  26.         {% endfor %}
  27.     </div>
  28. {% endif %}