function _msnf_fieldgroup_has_element in Multistep Nodeform 7
Helper function to check whether an element is nested within a fieldgroup or one of the fieldgroups child groups.
Parameters
<array> $groups: Array with all available groups (needed for recursion).
<object> $group: Group to search for the element.
<string> $element_name: Name of form element to find in $group.
<int> $depth: Maximum number of levels to recurse. Internally used only.
Return value
<boolean> TRUE if $element_name is in $group or one of its child groups, otherwise FALSE.
1 call to _msnf_fieldgroup_has_element()
- _msnf_hide_fields in ./
msnf.module - Hide all fields that are not associated to the current step.
File
- ./
msnf.module, line 1320 - Main functions for module "Multistep Nodeform".
Code
function _msnf_fieldgroup_has_element($groups, $group, $element_name, $depth = 10) {
if ($depth <= 0) {
// Recursion limit reached.
return FALSE;
}
$in_group = FALSE;
// Element is direct child of group?
$in_group = $in_group || in_array($element_name, $group->children);
if (!$in_group) {
// Check child groups.
foreach ($group->children as $child_group_name) {
if (isset($groups[$child_group_name])) {
$in_group = $in_group || _msnf_fieldgroup_has_element($groups, $groups[$child_group_name], $element_name, --$depth);
}
}
}
return $in_group;
}