- Issue created by @redneko
- First commit to issue fork.
- 🇵🇱Poland alorenc Wolsztyn, 🇵🇱
I was able to replicate the issue consistently.
I created the following nested group hierarchy:
- Level 1 (parent of Level 2)
- Level 2 (parent of Level 3)
- Level 3 (contains the body field)I then reorganized the structure using the Field Group UI:
- Level 3 becomes the top-level group
- It contains Level 2
- Which contains Level 1
- And Level 1 contains the body fieldI exported the configuration and noticed. The weight values were correctly updated. However, the field order in the YAML config remained unchanged, still reflecting the original nesting order.
It looks like the Field Group module builds the field group hierarchy based on the order of items in the YAML configuration file, instead of relying solely on the weight and parent_name properties.
This becomes problematic when reversing the hierarchy (e.g., changing a parent into a child or vice versa), because:
* The updated structure is not respected during render
* Fields and groups may not display correctly, even if weight and parent_name appear valid - 🇵🇱Poland alorenc Wolsztyn, 🇵🇱
The function field_group_remove_empty_form_groups expects that groups are ordered from parent to child
Added an additional function which orders groups. Thank you for the work alorenc.
I tested the fix on the site were I found the issue. The missing field group and its children are now displaying, and I did not find any evidence that this fix caused any new issues. I tried making new nodes with different configurations of field groups and found everything to work as expected.
The coding itself looked good to me, but I am not confident in this area. I will leave this issue in 'Needs review' so someone else can check that, and also corroborate that the fix works.