diff --git a/core/includes/form.inc b/core/includes/form.inc index efb59f7..499aca9 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1599,7 +1599,9 @@ function form_process_container($element, &$form_state) { } /** - * Returns HTML for a table with radio buttons or checkboxes. + * Prepares a 'tableselect' #type element for rendering. + * + * Adds a column of radio buttons or checkboxes for each row of a table. * * @param $variables * An associative array containing: @@ -1637,14 +1639,8 @@ function form_process_container($element, &$form_state) { * '#empty' => t('No content available.'), * ); * @endcode - * - * @ingroup themeable */ -function theme_tableselect($variables) { - $element = $variables['element']; - $table = array( - '#type' => 'table', - ); +function form_pre_render_tableselect(array $element) { $rows = array(); $header = $element['#header']; if (!empty($element['#options'])) { @@ -1684,7 +1680,7 @@ function theme_tableselect($variables) { // checkboxes/radios in the first table column. if ($element['#js_select']) { // Add a "Select all" checkbox. - $table['#attached']['library'][] = 'core/drupal.tableselect'; + $element['#attached']['library'][] = 'core/drupal.tableselect'; array_unshift($header, array('class' => array('select-all'))); } else { @@ -1693,14 +1689,11 @@ function theme_tableselect($variables) { array_unshift($header, ''); } } - $table += array( - '#header' => $header, - '#rows' => $rows, - '#empty' => $element['#empty'], - '#attributes' => $element['#attributes'], - ); - return drupal_render($table); + $element['#header'] = $header; + $element['#rows'] = $rows; + + return $element; } /** @@ -1792,7 +1785,6 @@ function form_process_tableselect($element) { * The processed element. * * @see form_process_tableselect() - * @see theme_tableselect() */ function form_process_table($element, &$form_state) { if ($element['#tableselect']) { diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b62ad74..d9674a9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2677,9 +2677,6 @@ function drupal_common_theme() { 'render element' => 'element', 'template' => 'textarea', ), - 'tableselect' => array( - 'render element' => 'element', - ), 'form_element' => array( 'render element' => 'element', 'template' => 'form-element', diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 8b4455b..c928565 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -522,10 +522,11 @@ function system_element_info() { '#input' => TRUE, '#js_select' => TRUE, '#multiple' => TRUE, + '#pre_render' => array('form_pre_render_tableselect'), '#process' => array('form_process_tableselect'), '#options' => array(), '#empty' => '', - '#theme' => 'tableselect', + '#theme' => 'table__tableselect', ); // Form structure.