function field_group_pre_render_tab in Field Group 7
Same name and namespace in other branches
- 7.2 field_group.module \field_group_pre_render_tab()
Implements field_group_pre_render_<format-type>. Format type: Vertical tab.
Parameters
$element The field group form element.:
$group The Field group object prepared for pre_render.:
$form The root element or form.:
File
- ./
field_group.module, line 1030 - Fieldgroup module.
Code
function field_group_pre_render_tab(&$element, $group, &$form) {
$view_mode = isset($form['#view_mode']) ? $form['#view_mode'] : 'form';
// Could be it never runs through htab.
$form['#attached']['js'][] = array(
'data' => array(
'field_group' => array(
'tabs' => $view_mode,
),
),
'type' => 'setting',
);
$add = array(
'#type' => 'fieldset',
'#id' => 'edit-' . $group->group_name,
'#title' => check_plain(t($group->label)),
'#collapsible' => $group->collapsible,
'#collapsed' => $group->collapsed,
'#attributes' => array(
'class' => explode(" ", $group->classes),
),
'#description' => $group->description,
);
// Front-end and back-end on configuration will lead
// to vertical tabs nested in a separate vertical group.
if ($view_mode != 'form') {
$add['#group'] = empty($group->parent_name) ? 'additional_settings' : $group->parent_name;
$add['#parents'] = array(
$add['#group'],
);
$element += $add;
}
elseif (!empty($group->parent_name)) {
$add['#group'] = $group->parent_name;
$element += $add;
}
else {
// Create the fieldgroup element.
$add['#parents'] = array(
'additional_settings',
);
$add['#group'] = 'additional_settings';
// Hardcoded to bring our extra additional vtabs on top.
$add['#weight'] = -30 + $group->weight;
// Check if the additional_settings exist for this type of form.
if (isset($form['additional_settings']['group']['#groups']['additional_settings'])) {
// Merge fieldgroups with the core additional settings.
$form['additional_settings']['group']['#groups']['additional_settings'][$group->group_name] = $add;
$form['additional_settings']['group']['#groups'][$group->group_name] = array(
'#group_exists' => TRUE,
);
// Nest the fields inside the appropriate structure.
foreach (element_children($element) as $fieldname) {
$form['additional_settings']['group']['#groups']['additional_settings'][$group->group_name][$fieldname] =& $element[$fieldname];
unset($element[$fieldname]);
}
}
else {
if (!isset($form['additional_settings']['#type'])) {
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => $group->weight,
'#theme_wrappers' => array(
'vertical_tabs',
),
'#prefix' => '<div class="field-group-' . $group->format_type . '-wrapper">',
'#suffix' => '</div>',
);
$form['#attached']['library'][] = array(
'system',
'drupal.collapse',
);
}
$form['additional_settings'][$group->group_name] = $add;
// Nest the fields inside the appropriate structure.
foreach (element_children($element) as $fieldname) {
$form['additional_settings'][$group->group_name][$fieldname] =& $element[$fieldname];
unset($element[$fieldname]);
}
}
}
}