Full ELMS Learning Network documentation
function theme_tableselect
×
Error message
User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).cis7 form.inc | theme_tableselect($variables) |
cle7 form.inc | theme_tableselect($variables) |
elmsmedia7 form.inc | theme_tableselect($variables) |
icor7 form.inc | theme_tableselect($variables) |
meedjum_blog7 form.inc | theme_tableselect($variables) |
mooc7 form.inc | theme_tableselect($variables) |
Returns HTML for a table with radio buttons or checkboxes.
Parameters
$variables: An associative array containing:
- element: An associative array containing the properties and children of the tableselect element. Properties used: #header, #options, #empty, and #js_select. The #options property is an array of selection options; each array element of #options is an array of properties. These properties can include #attributes, which is added to the table row's HTML attributes; see theme_table(). An example of per-row options:
$options = array(
array(
'title' => 'How to Learn Drupal',
'content_type' => 'Article',
'status' => 'published',
'#attributes' => array('class' => array('article-row')),
),
array(
'title' => 'Privacy Policy',
'content_type' => 'Page',
'status' => 'published',
'#attributes' => array('class' => array('page-row')),
),
);
$header = array(
'title' => t('Title'),
'content_type' => t('Content type'),
'status' => t('Status'),
);
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No content available.'),
);
Related topics
16 string references to the theme hook from theme_tableselect()
Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.
- accessibility_tests_list in sites/
all/ modules/ ulmus/ accessibility/ accessibility.admin.inc - Form for importing tests.
- bulk_export_export_form in sites/
all/ modules/ ulmus/ ctools/ bulk_export/ bulk_export.module - FAPI definition for the bulk exporter form.
- comment_admin_overview in modules/
comment/ comment.admin.inc - Form builder for the comment overview administration form.
- database_test_theme_tablesort in modules/
simpletest/ tests/ database_test.module - Output a form without setting a header sort.
- devel_variable_form in sites/
all/ modules/ ulmus/ devel/ devel.pages.inc
File
- includes/
form.inc, line 3346 - Functions for form and batch generation and processing.
Code
function theme_tableselect($variables) {
$element = $variables['element'];
$rows = array();
$header = $element['#header'];
if (!empty($element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach (element_children($element) as $key) {
$row = array();
$row['data'] = array();
if (isset($element['#options'][$key]['#attributes'])) {
$row += $element['#options'][$key]['#attributes'];
}
// Render the checkbox / radio element.
$row['data'][] = 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['data'][] = $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.
if ($element['#js_select']) {
// Add a "Select all" checkbox.
drupal_add_js('misc/tableselect.js');
array_unshift($header, array('class' => array('select-all')));
}
else {
// Add an empty header when radio buttons are displayed or a "Select all"
// checkbox is not desired.
array_unshift($header, '');
}
}
return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => $element['#empty'], 'attributes' => $element['#attributes']));
}