Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
when I have a status message following a warning message, the status message has also the warning class in it.
I think the problem is the attributes variable in the status-messages.html.twig which is not somehow reset for every loop in the for statement.
{% for type, messages in message_list %}
{%
set classes = [
'messages',
'messages--' ~ type,
]
%}
<div class="{{ attributes.addClass(classes).class }}" role="contentinfo" aria-label="{{ status_headings[type] }}">
{% if type == 'error' %}
<div role="alert">
{% endif %}
{% if status_headings[type] %}
<h2 class="visually-hidden">{{ status_headings[type] }}</h2>
{% endif %}
any ideas? where are the twig specialists?! :-)
greetings ifux
Comment | File | Size | Author |
---|---|---|---|
#5 | wrong_classes_on_status-2345005-5.patch | 2.19 KB | legolasbo |
Bildschirmfoto 2014-09-25 um 18.53.55.png | 82.42 KB | ifux |
Comments
Comment #1
tim.plunkettNo idea why this is done in twig. This would be much easier in PHP. I have no idea how to reset attributes in each loop.
Comment #2
damiankloip CreditAttribution: damiankloip commentedHmm, yes indeed. Looks like #2329853: Move miscellaneous theme.inc classes from preprocess to templates broke it?
Comment #3
tim.plunkettComment #4
legolasboI'll write some tests for this issue.
Comment #5
legolasboAttached patch adds tests for this issue, which will obviously fail since there is no patch yet.
Comment #7
lauriiiComment #8
lauriiiThis has been fixed there #2348783: drupal_set_message inherits previous style if set to 'status'