| 1 field_group.module | _field_group_is_empty_element(array $element, $entity, $child_name, array $groups) |
Determine if an element has non-empty children.
Parameters
array $element: The element to check.
string $entity: The entity type name.
string $child_name: The name of the child element.
array $groups: Array of group objects.
Return value
bool: TRUE if element has non-empty children, FALSE otherwise.
File
- core/
modules/ field_group/ field_group.module, line 538 - Field Group module.
Code
function _field_group_is_empty_element(array $element, $entity, $child_name, array $groups) {
$exceptions = array('user__account', 'comment__author');
$exception = $entity . '__' . $child_name;
if (in_array($exception, $exceptions)) {
return TRUE;
}
if (isset($element[$child_name]['#type'])
|| isset($element[$child_name]['#markup'])
|| isset($element[$child_name]['#prefix'])
|| isset($element[$child_name]['#suffix'])
) {
return TRUE;
}
// Prevent a double recursive loop (groups are already recursive looped in
// field_group_remove_empty_form_groups.
if (in_array($child_name, $groups)) {
return FALSE;
}
$children = element_children($element[$child_name]);
foreach ($children as $child) {
if (_field_group_is_empty_element($element[$child_name], $entity, $child, $groups)) {
return TRUE;
}
}
return FALSE;
}