function field_group_remove_empty_display_groups in Field Group 7.2
Same name and namespace in other branches
- 8.3 field_group.module \field_group_remove_empty_display_groups()
- 8 field_group.module \field_group_remove_empty_display_groups()
- 7 field_group.module \field_group_remove_empty_display_groups()
Remove empty groups on entity display.
Parameters
array $element: The element to check the empty state.
array $groups: Array of group objects.
1 call to field_group_remove_empty_display_groups()
File
- ./
field_group.module, line 1087 - Fieldgroup module.
Code
function field_group_remove_empty_display_groups(&$element, $groups) {
$empty_child = TRUE;
$empty_group = TRUE;
// Loop through the children for current element.
foreach (element_children($element) as $name) {
// Descend if the child is a group.
if (in_array($name, $groups)) {
$empty_child = field_group_remove_empty_display_groups($element[$name], $groups);
if (!$empty_child) {
$empty_group = FALSE;
}
}
elseif (!empty($element[$name])) {
$empty_group = FALSE;
}
}
// Reset an empty group.
if ($empty_group) {
$element = NULL;
}
return $empty_group;
}