function theme_office_hours_multiple_values in Office Hours 6.2
Same name and namespace in other branches
- 6 office_hours.theme.inc \theme_office_hours_multiple_values()
copied from content module's theme_content_multiple_values- we're taking out the draggable feature.
Theme the hour table form
File
- ./
office_hours.theme.inc, line 66
Code
function theme_office_hours_multiple_values($element) {
$field_name = $element['#field_name'];
$field = content_fields($field_name);
$output = '';
if ($field['multiple'] >= 1) {
$table_id = $element['#field_name'] . '_values';
$order_class = $element['#field_name'] . '-delta-order';
$required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
$header = array(
array(
'data' => t('!title: !required', array(
'!title' => $element['#title'],
'!required' => $required,
)),
'colspan' => 1,
),
);
$rows = array();
// Sort items according to '_weight' (needed when the form comes back after
// preview or failed validation)
$items = array();
foreach (element_children($element) as $key) {
if ($key !== $element['#field_name'] . '_add_more') {
$items[] =& $element[$key];
}
}
// dpm($items);
$items = _office_hours_arrange_day($items);
//this calls the function that arranges the first day of the week.
// Add the items as table rows.
foreach ($items as $key => $item) {
$delta_element = drupal_render($item['_weight']);
if (!($key % 2)) {
//this is an even row, start a new row array_keys
$cells = array(
drupal_render($item),
);
}
else {
//this is an odd row
$cells[] = drupal_render($item);
//we've add the second cell;
$rows[] = array(
'data' => $cells,
);
}
}
$output .= theme('table', $header, $rows, array(
'id' => $table_id,
'class' => 'office_hours_table content-multiple-table',
));
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
// $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
//drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
}
else {
foreach (element_children($element) as $key) {
$output .= drupal_render($element[$key]);
}
}
return $output;
}