Skip to content

[6.x] Expose expanded sections on tabs - #15694

Merged
jasonvarga merged 2 commits into
6.xfrom
tab-expanded-sections
Oct 21, 2026
Merged

jasonvarga merged 2 commits into
6.xfrom
tab-expanded-sections

Conversation

@jasonvarga

Copy link
Copy Markdown
Member

This PR makes Tab::expandedSections() public so code other than the CP publish form can use fieldset section expansion (added in #14297). It's a refactor; publish output is unchanged.

Previously the expansion lived in private methods that returned publish arrays, so only Tab::toPublishArray() could use it. Everything else calls $tab->sections(), which doesn't split sections around sectioned fieldset imports.

Changes

  • Tab::expandedSections() is now public and returns a Collection of Section objects. Tab::toPublishArray() maps them to publish arrays.
  • Section accepts an optional second constructor argument of already-resolved Fields, which fields() returns when set. Imported fieldset sections use this, so their fields keep the import's prefixes and config overrides.
  • When a Section has resolved fields, toPublishArray() maps them directly instead of going through Fields::toPublishArray(). That method's Blink key ignores field prefixes, so fields that differ only by prefix could otherwise share cached output. The old code avoided it the same way.
  • Tab::sections() and Tab::fields() are unchanged.

Backwards compatibility

  • I compared Tab::toPublishArray() output before and after with one large fixture, and it's identical. The fixture covered nested imports with inner and outer prefixes, config overrides on prefixed imports, collapsible/collapsed sections, empty sections, section_behavior: flatten, and multiple imports of the same fieldset.
  • The existing expansion tests pass unmodified.
  • expandedSections() going from private to public would only clash with an addon subclass of Tab that declares its own expandedSections().
  • If a fieldset section has a non-boolean collapsible/collapsed value (e.g. a quoted 'yes'), it now ends up as a boolean in the publish array, the same as blueprint sections already do. YAML booleans are unaffected.

Why

The forms-2 work (the forms API and form:create) will use expandedSections() so forms show fieldset sections the same way the CP does.

Possible follow-ups

These still flatten sectioned imports via $tab->sections() on 6.x. Switching them to expandedSections() would be a behaviour change, so they're left alone here:

  • Forms\Tags (form:create sections)
  • Auth\UserTags (user register/profile forms)

jasonvarga and others added 2 commits October 21, 2026 15:41
Tab::expandedSections() is now public and returns Section objects instead of publish arrays, so code other than the CP publish form can use fieldset section expansion. Sections can now hold pre-resolved fields, which imported fieldset sections use so their fields keep prefixes and config overrides. Publish output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit d66e660 into 6.x Oct 21, 2026
64 checks passed
@jasonvarga
jasonvarga deleted the tab-expanded-sections branch October 21, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant