function theme_tableform in Tableform 7
Returns HTML for a tableform form element.
Parameters
$variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #title, #header, #options, #attributes
1 theme call to theme_tableform()
- tableform_element_info in ./
tableform.module - Implementation of hook_element_info();
File
- ./
tableform.module, line 85
Code
function theme_tableform($variables) {
$element = $variables['element'];
$rows = array();
$header = array();
// process header cells
$header_field = isset($element['#tf_header']) ? '#tf_header' : '#header';
if (!empty($element[$header_field])) {
foreach ($element[$header_field] as $key => $cell) {
$header[] = tableform_render_cell($element, $cell, $key);
}
}
// process rows
$rows_field = isset($element['#tf_rows']) ? '#tf_rows' : '#options';
if (!empty($element[$rows_field])) {
foreach ($element[$rows_field] as $row) {
$rendered = array(
'data' => array(),
);
foreach ($row as $key => $cell) {
$rendered['data'][] = tableform_render_cell($element, $cell, $key);
}
$rows[] = $rendered;
}
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
'empty' => $element['#empty'],
'attributes' => $element['#attributes'],
));
}