diff --git i/field_group.module w/field_group.module index 357a917..641ea03 100644 --- i/field_group.module +++ w/field_group.module @@ -2034,6 +2034,9 @@ function field_group_fields_nest(&$element, &$vars = NULL) { } $group_references[$group_name]['#array_parents'] = $parents; $element['#fieldgroups'][$group_name]->array_parents = $parents; + // Remove self from parents and set #field_parents + array_pop($parents); + $group_references[$group_name]['#field_parents'] = $parents; } } @@ -2084,18 +2087,17 @@ function field_group_fields_nest(&$element, &$vars = NULL) { // list intact (but if it is a field we don't mind). $group_references[$parent_name][$child_name] = &$element[$child_name]; $group_references[$parent_name]['#weight'] = $element['#fieldgroups'][$parent_name]->weight; - // Set #array_parents of group child element + // Prepend #array_parents & #field_parents of group child element & its element_children, if set $group_child = &$group_references[$parent_name][$child_name]; $group_parents = $group_references[$parent_name]['#array_parents']; - if (isset($group_child['#array_parents'])) { - // array_unique in case it's already prepended ... somehow - $group_child['#array_parents'] = array_unique(array_merge($group_parents, $group_child['#array_parents'])); - } - // And recursively for element's children - foreach (_element_children_recursive_ref($group_child) as &$group_child_child) { - if (isset($group_child_child['#array_parents'])) { - $group_child_child['#array_parents'] = array_unique(array_merge($group_parents, $group_child['#array_parents'])); - } + $process_elements = array_merge(array(&$group_child), _element_children_recursive_ref($group_child)); + foreach ($process_elements as $key => $current_element) { + if (isset($current_element['#array_parents'])) { + $process_elements[$key]['#array_parents'] = array_merge($group_parents, $current_element['#array_parents']); + } + if (isset($current_element['#field_parents'])) { + $process_elements[$key]['#field_parents'] = array_merge($group_parents, $current_element['#field_parents']); + } } }