I have a form with three field groups, arranged as horizontal tabs.
On one of these tabs, I have twelve fields. For eight of these fields, I would like to arrange them inside of a table.
These fields are date popup fields.
Each of the fields has its label removed; I'm just trying to have a table where the field labels are in the header and the actual tags are inside the table rows.
I'm using the code below to remove the labels (it was difficult to figure out, so if anyone can use it)
However, I'm not yet sure how to then place the resulting fields into a table format.
My first thought was a theme function for the entire form, but how would I insert the table into one of the tabs? drupal_render() would not work for that.
Will I just have to go through each item individually?
Thanks for your help.
<?php
function MYMODULE_form_recruitment_process_node_form_alter(&$form, &$form_state, $form_id) {
$date_fields = array(
'field_special_1',
'field_special_2',
'field_special_3',
'field_special_4',
'field_special_5',
'field_special_6',
'field_special_7',
'field_special_8',
'field_special_9',
'field_special_10',
);
foreach ($date_fields as $field_name) {
$form[$field_name][LANGUAGE_NONE][0]['#title_display'] = 'invisible';
}
}
function MYMODULE_element_info_alter(&$type) {
if (isset($type['date_popup'])) {
$type['date_popup']['#process'][] = 'MYMODULE_date_popup_process';
}
}
function MYMODULE_date_popup_process($element, $form_state, $complete_form) {
// Get the field name and create an array of fields we want to change.
$field_name = $element['#field']['field_name'];
$valid_fields = array(
'field_special_1',
'field_special_2',
'field_special_3',
'field_special_4',
'field_special_5',
'field_special_6',
'field_special_7',
'field_special_8',
'field_special_9',
'field_special_10',
);
// If it's not the field we want, return it unchanged.
if (!in_array($field_name, $valid_fields)) {
return $element;
}
$element['date']['#description'] = "";
$element['date']['#title_display'] = 'invisible';
$element['time']['#descsription'] = "";
$element['time']['#title_display'] = 'invisible';
return $element;
}