Commit cb009a32 authored by Dries's avatar Dries

- Patch #720202 by naxoc, kkaefer: theme_table() doesn't use thead with empty cells.

parent 224243b8
......@@ -1663,6 +1663,11 @@ function theme_table($variables) {
}
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
$rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message')));
}
// Format the table header:
if (count($header)) {
$ts = tablesort_init($header);
......@@ -1680,11 +1685,6 @@ function theme_table($variables) {
$ts = array();
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
$rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message')));
}
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";
......
......@@ -95,6 +95,17 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
$this->assertNoRaw('sticky-enabled', t('Table does not have a class of sticky-enabled because $sticky = FALSE.'));
drupal_static_reset('drupal_add_js');
}
/**
* Tests that the table header is printed even if there are no rows. And that
* the empty text is displayed correctly.
*/
function testThemeTableWithEmptyMessage() {
$header = array(t('Header 1'), t('Header 2'));
$this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.')));
$this->assertRaw('<tr class="odd"><td colspan="2" class="empty message">No strings available.</td>', t('Correct colspan was set on empty message.'));
$this->assertRaw('<thead><tr><th>Header 1</th>', t('Table header was printed.'));
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment