Problem/Motivation
When nested field groups are configured for a form display, we are seeing empty groups rendered on other entity forms for that bundle such as when using the Scheduled Transitions module.
It seems that all but the lowest level of groups are rendered, e.g if you have Group A > Group B > Field Z, then on the Scheduled Transitions Form (and add form) you'll see Group A rendered but it will be empty. Adding a Group C under Group B will show Group A > Group B (empty).
Proposed resolution
Not quite sure...most likely somewhere in field_group_remove_empty_form_groups
Remaining tasks
Identify bug, write tests, fix it.
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2019-12-04 at 9.32.14 am.png | 33.29 KB | acbramley | |
| Screen Shot 2019-12-04 at 9.32.09 am.png | 31.78 KB | acbramley |
Issue fork field_group-3098550
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:


Comments
Comment #2
acbramley commentedComment #3
acbramley commentedThis also happens on the Children tab with the Entity hierarchy module
Comment #4
acbramley commentedComment #5
acbramley commentedComment #6
acbramley commentedThis is much easier to reproduce on a simple edit form by nesting 2 field groups, with a single field as a child, then using hook_field_access to deny access to that field. I will work on a test now.
Comment #7
acbramley commentedHere's a failing test. I spent quite a bit of time trying to figure it out using the view context but it looks like this bug only exists in the form context.
Comment #8
mnico commentedHello, recently I had to try to find a solution. I upload a patch with the test published by @acbramley to see if it goes well;)
Comment #9
acbramley commentedNice work @mnico! That fixes the issue for me.
Comment #10
tim-dielsIndeed nice work! This works for me also
Comment #11
dshields commentedWorks for me.
Comment #12
acbramley commentedRerolled against latest dev. Removed the trait changes as we now have similar logic in there.
Comment #13
weekbeforenextPatch #12 works for me. Thanks!
Comment #14
rp7 commentedI was using the patch from #2849279: Make the moderation control form an entity form so that it validates entities before save and field group tabs were appearing on the content moderation form rendered by the content_moderation_info_block module. Patch in #12 fixed this. Thank you!
Comment #15
mandclu commentedI've tried the patch in #12, and it doesn't seem to resolve the problem of empty fieldsets being rendered when the fields don't appear because of translation settings, as originally reported in #3200703: Empty fieldgroups are showing in forms (updated)
Comment #16
rp7 commentedI started to wonder why these field groups are actually rendered at all on forms such as the scheduled transitions add form. It appears the Field Group is doing this based on the active form display: https://git.drupalcode.org/project/field_group/-/blob/8.x-3.x/field_grou... - which sounds logical.
The scheduled transitions add form, however, is a custom (entity) form but it's form state has a form display that is actually incorrect (in my case it has the "default" form display, but that's actually not the one being displayed). Possibly this is something that should/can be fixed in the Scheduled Transitions module (and possibly other modules, such as Content Moderation Info Block as well). I have created a ticket in the Scheduled Transitions module's issue queue with a possible fix: #3264674: Field groups are added to the scheduled transitions add form .
Comment #17
rp7 commentedRerolled against latest dev.
Comment #18
maxilein commentedIt does not apply any more to the later devs.
e.g. drupal/field_group dev-3.x eb2167b7
Comment #19
nadim hossain commentedRe-rolled the patch 12 against - 8.x-3.6
Comment #21
acbramley commentedPatches don't run tests, rolled into an MR.
Comment #22
acbramley commentedFixed CSpell failure, the phpstan failure is on HEAD.
Comment #23
maxilein commentedIt does apply to fieldgroup 3.6.0.
Thank you
Comment #24
anybodyThank you for your great work and tests here @acbramley!
Comment #26
anybody