I'm running the 1.x-dev branch and running into issues with nested field groups where they are out of order by default; ie: "child, child, parent, child".

Presumably this order is based on the element's creation order because it doesn't take the weight into account.

In field_group_fields_nest(), even though the hierarchy gets resolved properly and stored in $group_references, the groups are still passed to field_group_pre_render() in their original order , so in our case, the parent will get rendered before the last child. This obviously means that the display gets broken.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexweber’s picture

Status: Active » Needs review
FileSize
1.7 KB

This is what fixed it for me, not sure if it's an acceptable general solution but I just always make sure that if there are nested field groups that the parents get pre-rendered last.

a.ross’s picture

This is what happens in the theme layer. The render array is themed from the bottom of the hierarchy to the top. It therefore makes sense to do anything that messes with the hierarchy of the render array in theme functions and not pre render functions. What field group are you having issues with?

alexweber’s picture

@a.ross My issue is with the "Foundation section" field group, provided by the Foundation Field Groups's 7.x-2.x-dev branch.

a.ross’s picture

Status: Needs review » Needs work

Changed status of the wrong issue.

It seems to me that this is a bug on that module's end. This bit of code in foundation_group_field_group_pre_render is incorrect, as it changes the hierarchy, like I said. This should only be done in theme functions.

  foreach ($group->children as $field_name) {
    $fields[$field_name] = $element[$field_name];
  }

Have a look at this commit for inspiration.

a.ross’s picture

Also, the comment you were referring to is misguided. The order in which groups are stored in the database, and in which they're looped over has nothing to do with the order in which they're rendered. Have a look at http://api.drupal.org/api/drupal/includes!common.inc/function/element_children/7

alexweber’s picture

@a.ross, thanks for the help!

nils.destoop’s picture

Project: Field Group » ZURB Section
Issue summary: View changes

Moving this to the correct module then.

alexweber’s picture

Status: Needs work » Closed (works as designed)

This has already been worked around in the latest version of the module, we're fine! :)