Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | field_group-1995738-field_group_fields_nest.patch | 1.7 KB | alexweber |
Comments
Comment #1
alexweber CreditAttribution: alexweber commentedThis 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.
Comment #2
a.ross CreditAttribution: a.ross commentedThis 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?
Comment #3
alexweber CreditAttribution: alexweber commented@a.ross My issue is with the "Foundation section" field group, provided by the Foundation Field Groups's 7.x-2.x-dev branch.
Comment #4
a.ross CreditAttribution: a.ross commentedChanged 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.Have a look at this commit for inspiration.
Comment #5
a.ross CreditAttribution: a.ross commentedAlso, 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
Comment #6
alexweber CreditAttribution: alexweber commented@a.ross, thanks for the help!
Comment #7
nils.destoop CreditAttribution: nils.destoop commentedMoving this to the correct module then.
Comment #8
alexweber CreditAttribution: alexweber commentedThis has already been worked around in the latest version of the module, we're fine! :)