Problem/Motivation
If you have both vertical and horizontal tabs on the same page, the 'required' functionality will not work since modules/contrib/field_group/formatters/tabs/tabs.js is only called with whichever happens first: horizontal or vertical
This is because 'tabs' is considered the 'format type' rather than separation between the two tab types. This means the settings passed will either be 'horizontal' or 'vertical', not both.
Steps to reproduce
- On the same entity, create both horizontal and vertical tab groups with required fields
- Ensure that 'Mark group as required if it contains required fields' is ticked
Proposed resolution
Process both horizontal and vertical tabs if existing
Remaining tasks
Refactor the code to allow for this
User interface changes
All field groups with required fields are highlighted as required even if there is a mix of horizontal and vertical tabs.
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | after.png | 72.71 KB | scott_euser |
| #3 | before.png | 72.67 KB | scott_euser |
Issue fork field_group-3505096
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 #3
scott_euser commentedBefore:
After:
Comment #4
scott_euser commentedTests pass fine once #3491233: Fix Drupal 10.4 RC1 error with field_ui.js is merged (applied manually locally and ran tests).
Phpcs, cspell, and eslint are all existing warnings. Probably best not to scope creep and fix here, so leaving as is.
Comment #5
stacypendell commentedWe're seeing a similar issue fixed by this patch - thank you!
In our case, two content types have both vertical and horizontal tabs. The first set of horizontal tabs disappears entirely when the module is upgraded from 3.6 to 4.0.0. The missing tab group reappears when the patch is applied. No 'required' functionality is involved. None of the other tab groups are affected, only the first one.
I'm happy to provide more information or do more testing if that would help.
Comment #7
benstallings commentedClaude Code says:
PHP Changes (field_group.module)
field_group_get_settings_key() — correct approach, one concern
The key construction ($group->format_type . $group->format_settings['direction']) correctly produces tabsvertical and tabshorizontal, which align with the JS dispatch lookup.
However, the drupalSettings attachment on lines 455-461 and 485-491 uses = (assignment), not += (merge):
This replaces the entire field_group settings array each time a group is processed. If a page has three groups (e.g. vertical tabs, horizontal tabs, and an accordion), only the last one processed will have its settings survive. This was a pre-existing bug — the branch doesn't introduce it — but it means this fix may still not fully work on pages with more than two field groups. Worth noting in the issue, though not something this branch needs to solve.
Docblock: Missing blank line between @param and @return (Drupal coding standards require it). Line 438 → 439 should have a blank line.
---
JS Changes (formatters/tabs/tabs.js)
Clean refactor. The logic is extracted into a standalone executeTabProcessing function, and two effect objects reference it:
The dispatch in field_group.js:30-39 iterates Drupal.FieldGroup.Effects, derives the settings key by lowercasing the effect name and stripping process, then looks up settings.field_group[type]. The keys produced:
This works correctly. The direction value is passed through in groupInfo.settings.direction, so the inner logic ($this.data(\${direction}Tab`)`) continues to resolve properly.
Backward compatibility: The old processTabs effect name is removed. Any third-party code that referenced Drupal.FieldGroup.Effects.processTabs directly will break. This is unlikely but worth mentioning in the change record.
---
Key Points
1. The dispatch key matching is correct — PHP and JS align properly
2. The = vs += for drupalSettings is a pre-existing issue, not introduced here, but it limits how many distinct field group types can coexist on one page
3. Minor: docblock missing blank line before @return
4. Minor: removal of processTabs is a (small) API break for any code referencing it directly
Comment #8
benstallings commentedComment #9
benstallings commentedComment #11
anybodyThank you for the fixes and the tests. LGTM! Merging!
Comment #12
anybody