function theme_conditional_fields_table in Conditional Fields 7.3
Returns HTML for Conditional Fields dependencies tables.
Parameters
$variables: An associative array containing:
- elements: An associative array containing a Form API structure to be rendered as a table.
1 theme call to theme_conditional_fields_table()
- conditional_fields_element_info in ./
conditional_fields.module - Implements hook_element_info().
File
- includes/
conditional_fields.admin.inc, line 325 - Administration of dependencies.
Code
function theme_conditional_fields_table($variables) {
$elements = $variables['elements'];
$table = array();
// Add table headers and attributes.
foreach (array(
'header',
'attributes',
) as $key) {
if (isset($elements["#{$key}"])) {
$table[$key] = $elements["#{$key}"];
}
}
// Dependencies rows.
foreach (element_children($elements['dependencies']) as $dependency) {
foreach (element_children($elements['dependencies'][$dependency]) as $cell_key) {
$cell = array(
'data' => drupal_render($elements['dependencies'][$dependency][$cell_key]),
);
foreach (array(
'#colspan',
'#rowspan',
) as $row_attribute) {
if (isset($elements['dependencies'][$dependency][$cell_key][$row_attribute])) {
$cell[ltrim($row_attribute, '#')] = $elements['dependencies'][$dependency][$cell_key][$row_attribute];
}
}
$table['rows'][$dependency][] = $cell;
}
}
// Add new dependency row.
$table['rows'][] = array(
drupal_render($elements['add_new_dependency']['dependent']),
drupal_render($elements['add_new_dependency']['dependee']),
array(
'data' => drupal_render($elements['add_new_dependency']['state']) . drupal_render($elements['add_new_dependency']['condition']),
'colspan' => 2,
),
array(
'data' => drupal_render($elements['add_new_dependency']['actions']),
'colspan' => 2,
),
);
return theme('table', $table);
}