Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.42 KB

tab.mdx

File metadata and controls

58 lines (38 loc) · 1.42 KB

Tab

A UI-only divider that groups fields into labelled tabs within a meta box.


PHP API

Field::tab(string $key): TabField

The key is used as the tab identifier; the label is the tab title.

->placement('top'|'left'): static

Where the tab bar sits: top (default) or left, a vertical list beside the fields. The first tab of a set decides for the whole set.


Storage

UI-only — never stored. Tab fields are stripped from the save pipeline payload.


Example

Field::group('portfolio_details')
    ->where('post_type', '==', 'portfolio')
    ->fields([

        Field::tab('main')->label('Main'),
            Field::text('client_name')->label('Client'),
            Field::date('launch_date')->label('Launch Date'),

        Field::tab('media')->label('Media'),
            Field::image('hero_image')->label('Hero Image'),
            Field::gallery('screenshots')->label('Screenshots'),

        Field::tab('seo')->label('SEO'),
            Field::text('meta_title')->label('Meta Title'),
            Field::textarea('meta_description')->label('Meta Description'),

    ])
    ->register();

Fields between two tab() calls belong to the first tab. Fields after the last tab call belong to that tab.


Notes

  • Tab fields are purely visual — they have no value and are not included in REST API responses.
  • A Tab must have a ->label() for the tab title to be readable.