diff --git a/includes/form.inc b/includes/form.inc index 8a17878..0f9084f 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -3800,6 +3800,24 @@ function form_pre_render_fieldset($element) { } } + if (isset($element['#group'])) { + $group = $element['#group']; + // If this element belongs to a group, but the group-holding element does + // not exist, we need to render it (at its original location). + if (!isset($element['#groups'][$group]['#group_exists'])) { + // Intentionally empty to clarify the flow; we simply return $element. + } + // If we injected this element into the group, then we want to render it. + elseif (!empty($element['#group_fieldset'])) { + // Intentionally empty to clarify the flow; we simply return $element. + } + // Otherwise, this element belongs to a group and the group exists, so we do + // not render it. + elseif (element_children($element['#groups'][$group])) { + $element['#printed'] = TRUE; + } + } + return $element; }