Hope this helps someone.
I've noticed that if you submitted something like an image that didn't validate, no error message would show. After a bit of investigation, it appears that it's because the javascript for better messages is only included if there is a message on the page, which of course won't work when the page is being updated via ajax or otherwise without a refresh.
I'm afraid I'm still not quite comfortable with patching yet, so for now, you need to change the theme_better_messages function in better_messages.module on line 50 (full function shown for context) from:
function theme_better_messages($display = NULL) {
print "theme";
$output = '';
$better_messages = better_messages_process_visibility();
$access = user_access('access better messages');
$message = drupal_get_messages($display, false);
if ($better_messages && $access && !empty($message)) {
$disable_autoclose = array_key_exists('error', $message);
better_messages_add_files($disable_autoclose);
$message = theme('better_messages_content', $display);
// We save the intial output to SESSION so we can put it in <noscript> on page_preprocess
$_SESSION['original_messages'] = $message;
$message_skin = theme('better_messages', $message);
// We add a special ID so that JavaScript knows what to handle. Changing the ID will break JavaScript handling code.
$output = "<div id=\"better-messages-wrapper\" style=\"display:none;overflow:visible;position:absolute;z-index:9999;\">\n".
$message_skin ."\n</div>\n";
}
else { $output = theme('better_messages_content', $display); }
return $output;
}
to:
function theme_better_messages($display = NULL) {
$output = '';
$better_messages = better_messages_process_visibility();
$access = user_access('access better messages');
$message = drupal_get_messages($display, false);
if ($better_messages && $access) {
$disable_autoclose = array_key_exists('error', $message);
better_messages_add_files($disable_autoclose);
if(!empty($message)) {
$message = theme('better_messages_content', $display);
// We save the intial output to SESSION so we can put it in <noscript> on page_preprocess
$_SESSION['original_messages'] = $message;
$message_skin = theme('better_messages', $message);
// We add a special ID so that JavaScript knows what to handle. Changing the ID will break JavaScript handling code.
$output = "<div id=\"better-messages-wrapper\" style=\"display:none;overflow:visible;position:absolute;z-index:9999;\">\n".
$message_skin ."\n</div>\n";
}
}
else { $output = theme('better_messages_content', $display); }
return $output;
}
Comments
Comment #1
viesulis commentedThanks, This was helpful!
Comment #2
bucefal91 commentedThe version 6.x is no longer supported.