The following function from at_core/inc/theme.inc creates more than one div with id="messages" if there are messages of more than one type to be displayed, leading to invalid HTML:

<?php
 
function adaptivetheme_status_messages($vars) {
 
$display = $vars['display'];
 
$output = '';

 
$status_heading = array(
   
'status' => t('Status message'),
   
'error' => t('Error message'),
   
'warning' => t('Warning message'),
  );
  foreach (
drupal_get_messages($display) as $type => $messages) {
   
$output .= "<div id="messages"><div class="messages $type">";
    if (!empty(
$status_heading[$type])) {
     
$output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>";
    }
    if (
count($messages) > 1) {
     
$output .= " <ul>";
      foreach (
$messages as $message) {
       
$output .= '  <li>' . $message . "</li>";
      }
     
$output .= " </ul>";
    }
    else {
     
$output .= $messages[0];
    }
   
$output .= "</div></div>";
  }
  return
$output;
}
 
?>

Comments

Jeff Burnz’s picture

Assigned:Unassigned» Jeff Burnz

Yeah, it needs to be fixed, thanks for posting the issue, I have been meaning to fix this for ages.

Jeff Burnz’s picture

Status:Active» Fixed

This is what it should be like, with just one ID wrapper, not one for each message, since they already have wrappers - will commit shortly:

<?php
function adaptivetheme_status_messages($vars) {
 
$display = $vars['display'];
 
$output = '';

 
$status_heading = array(
   
'status' => t('Status message'),
   
'error' => t('Error message'),
   
'warning' => t('Warning message'),
  );

 
$output .= "<div id="messages">";

  foreach (
drupal_get_messages($display) as $type => $messages) {
   
$output .= "<div class="messages $type">";
    if (!empty(
$status_heading[$type])) {
     
$output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>";
    }
    if (
count($messages) > 1) {
     
$output .= " <ul>";
      foreach (
$messages as $message) {
       
$output .= '  <li>' . $message . "</li>";
      }
     
$output .= " </ul>";
    }
    else {
     
$output .= $messages[0];
    }
   
$output .= "</div>";
  }

 
$output .= "</div>";

  return
$output;
}
?>
Jeff Burnz’s picture

Committed.

cspitzlay’s picture

Wow, that was quick. :)
Thanks.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.