| Versionen | |
|---|---|
| drupal7 | theme_tableselect($element) |
Format a table with radio buttons or checkboxes.
$element An associative array containing the properties and children of the tableselect element. Properties used: header, options, empty, js_select.
A themed HTML string representing the table.
includes/
<?php
function theme_tableselect($element) {
$rows = array();
if (!empty($element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach ($element['#options'] as $key => $value) {
$row = array();
// Render the checkbox / radio element.
$row[] = drupal_render($element[$key]);
// As theme_table only maps header and row columns by order, create the
// correct order by iterating over the header fields.
foreach ($element['#header'] as $fieldname => $title) {
$row[] = $element['#options'][$key][$fieldname];
}
$rows[] = $row;
}
// Add an empty header or a "Select all" checkbox to provide room for the
// checkboxes/radios in the first table column.
$first_col = $element['#js_select'] ? array(theme('table_select_header_cell')) : array('');
$header = array_merge($first_col, $element['#header']);
}
else {
// If there are no selectable options, display the empty text over the
// entire width of the table.
$header = $element['#header'];
$rows[] = array(array('data' => $element['#empty'], 'colspan' => count($header)));
}
return theme('table', $header, $rows);
}
?>
Kommentare
Kommentar hinzufügen