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.
Using 7.x-1.5, create a content type with the following nested field groups and no fields:
- Level A
- Level B
- Level 1
- Level 2
- Level 3
- Level 2
The node add/edit forms (and any VBO forms you create) will have a single empty fieldset called "Level 1".
It seems as though this module can only hide the two deepest levels in any given set of nested groups.
As far as I can tell, this is because _field_group_is_empty_element()
returns TRUE
whenever any child element has a #type
set, even though that child might just be another empty field group.
I've tried using 7.x-1.x-dev instead but that actually makes things worse and shows all of the fieldsets.
Comment | File | Size | Author |
---|---|---|---|
#4 | field_group-hide-empty-2897626-4.patch | 1.22 KB | marc.groth |
#2 | field_group-hide-empty-2897626-2.patch | 856 bytes | morbiD |
Comments
Comment #2
morbiD CreditAttribution: morbiD commentedHmm, shouldn't
_field_group_is_empty_element()
check if#access
isFALSE
before bothering to check the#type
?Here's a patch that seems to produce the correct behaviour in my use case. Not sure if it has any negative effects elsewhere though...
Comment #3
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe patch in #2 to field_group.module applied cleanly to the latest field_group 7.x-1.x-dev, but still needs review.
Comment #4
marc.groth CreditAttribution: marc.groth commentedThis is still occurring in the latest version on the 3.x branch. The empty fieldsets also show on the 'Scheduled Transitions' tab (when using the https://drupal.org/project/scheduled_transitions module).
Attached is a patch that fixes this behavior. Not sure if it's the best way to achieve this; but it does the job for nested fieldsets (up to 3 x nested from my testing).