status-messages.html.twig 1.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
{#
/**
 * @file
 * Default theme implementation for status messages.
 *
 * Displays status, error, and warning messages, grouped by type.
 *
 * An invisible heading identifies the messages for assistive technology.
 * Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
 * for info.
 *
12 13 14
 * Add an ARIA label to the contentinfo area so that assistive technology
 * user agents will better describe this landmark.
 *
15 16 17
 * Available variables:
 * - message_list: List of messages to be displayed, grouped by type.
 * - status_headings: List of all status types.
18 19
 * - attributes: HTML attributes for the element, including:
 *   - class: HTML classes.
20 21 22 23 24
 *
 * @ingroup themeable
 */
#}
{% for type, messages in message_list %}
25
  <div role="contentinfo" aria-label="{{ status_headings[type] }}"{{ attributes|without('role', 'aria-label') }}>
26 27
    {% if type == 'error' %}
      <div role="alert">
28
    {% endif %}
29 30 31 32
      {% if status_headings[type] %}
        <h2 class="visually-hidden">{{ status_headings[type] }}</h2>
      {% endif %}
      {% if messages|length > 1 %}
33
        <ul>
34
          {% for message in messages %}
35
            <li>{{ message }}</li>
36 37 38
          {% endfor %}
        </ul>
      {% else %}
39
        {{ messages|first }}
40 41 42
      {% endif %}
    {% if type == 'error' %}
      </div>
43 44 45
    {% endif %}
  </div>
{% endfor %}