function field_group_build_entity_groups in Field Group 7
Same name and namespace in other branches
- 8.3 field_group.module \field_group_build_entity_groups()
- 8 field_group.module \field_group_build_entity_groups()
- 7.2 field_group.module \field_group_build_entity_groups()
Preprocess/ Pre-render callback.
Parameters
$vars preprocess vars or form element:
$type The type of object being rendered:
Return value
$element Array with re-arranged fields in forms.
See also
field_group_theme_registry_alter
1 call to field_group_build_entity_groups()
- field_group_form_pre_render in ./
field_group.module - Pre render callback for rendering groups.
1 string reference to 'field_group_build_entity_groups'
- field_group_theme_registry_alter in ./
field_group.module - Implements hook_theme_registry_alter().
File
- ./
field_group.module, line 1959 - Fieldgroup module.
Code
function field_group_build_entity_groups(&$vars, $type) {
if ($type == 'form') {
$element =& $vars;
$nest_vars = NULL;
}
else {
$element =& $vars['elements'];
$nest_vars =& $vars;
}
// No groups on the entity.
if (empty($element['#fieldgroups'])) {
return $element;
}
// Nest the fields in the corresponding field groups.
field_group_fields_nest($element, $nest_vars);
// Allow others to alter the pre_rendered build.
drupal_alter('field_group_build_pre_render', $element);
// Return the element on forms.
if ($type == 'form') {
return $element;
}
// No groups on the entity. Prerender removed empty field groups.
if (empty($element['#fieldgroups'])) {
return $element;
}
// Put groups inside content if we are rendering an entity_view.
foreach ($element['#fieldgroups'] as $group) {
if (!empty($element[$group->group_name]) && $type != 'user_profile') {
$vars['content'][$group->group_name] = $element[$group->group_name];
}
elseif (!empty($element[$group->group_name])) {
$vars['user_profile'][$group->group_name] = $element[$group->group_name];
}
}
// New css / js can be attached.
drupal_process_attached($element);
}