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

  1. On the same entity, create both horizontal and vertical tab groups with required fields
  2. 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

CommentFileSizeAuthor
#3 after.png72.71 KBscott_euser
#3 before.png72.67 KBscott_euser
Command icon 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

scott_euser created an issue. See original summary.

scott_euser’s picture

Assigned: scott_euser » Unassigned
Status: Active » Needs review
StatusFileSize
new72.67 KB
new72.71 KB

Before:

After:

scott_euser’s picture

Tests 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.

stacypendell’s picture

We'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.

jeroent made their first commit to this issue’s fork.

benstallings’s picture

Status: Needs review » Reviewed & tested by the community

Claude 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):

  $element['#attached']['drupalSettings']['field_group'] = [
      field_group_get_settings_key($group) => [ ... ],
  ];

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:

  Drupal.FieldGroup.Effects.processTabsVertical = { execute: executeTabProcessing };
  Drupal.FieldGroup.Effects.processTabsHorizontal = { execute: executeTabProcessing };

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:

  - processTabsVertical → tabsvertical (matches PHP key tabs + vertical)
  - processTabsHorizontal → tabshorizontal (matches PHP key tabs + horizontal)

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

benstallings’s picture

Assigned: Unassigned » benstallings
benstallings’s picture

Assigned: benstallings » Unassigned
Status: Reviewed & tested by the community » Needs review

anybody made their first commit to this issue’s fork.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for the fixes and the tests. LGTM! Merging!

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.