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.
The function editablefields_view() has an area that returns messages set by drupal_set_message() only if they are the default level of 'status'. Is there any particular reason this design choice was made? It would seem that 'warning' and 'error' level messages would also be pretty important for an end-user to be made aware of whether or not their change took place and what potentially went wrong.
Original:
<?php
$messages = drupal_get_messages('status', TRUE);
if (count($messages) > 0) {
foreach ($messages as $type => $messages) {
foreach ($messages as $message) {
$output .= '<div class="messages ' . $type . '">' . $message . "</div>";
}
}
}
?>
One solution:
<?php
$messages = drupal_get_messages();
if (count($messages) > 0) {
foreach ($messages as $type => $messages) {
foreach ($messages as $message) {
$output .= '<div class="messages ' . $type . '">' . $message . "</div>";
}
}
}
?>
Optimal solution that AHAH uses:
<?php
$output .= theme('status_messages');
?>
Comment | File | Size | Author |
---|---|---|---|
#1 | editablefields-drupal_get_messages_fix-1821168-1.patch | 734 bytes | vishun |
Comments
Comment #0.0
vishun CreditAttribution: vishun commentedIncluded php tags for syntax highlighting
Comment #1
vishun CreditAttribution: vishun commentedComment #1.0
vishun CreditAttribution: vishun commentedRemoved specification of function arguments that match the default.
Comment #2
joelpittetLast update was 2012, going to close as outdated because it's against 6.x branch.