Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Collapsible

Layout-only collapsible container for sub-fields. Like Row, sub-fields are promoted as top-level columns with no prefix. Unlike Group, which creates prefixed columns (group__subfield), Collapsible is purely a UI container.

Storage

Collapsible fields do not create their own column. Each sub-field becomes a top-level column using its plain name — no prefix is added. This is identical to Row storage.

For example, a collapsible with sub-fields meta_title and meta_description creates columns:

  • meta_title TEXT
  • meta_description TEXT

Definition

crap.fields.collapsible({
    name = "seo_section",
    admin = {
        label = "SEO Settings",
        -- collapsed defaults to true; set false to start expanded
        -- collapsed = false,
    },
    fields = {
        crap.fields.text({ name = "meta_title" }),
        crap.fields.textarea({ name = "meta_description" }),
    },
})

API Representation

In API responses, collapsible sub-fields appear as flat top-level fields (not nested):

{
  "meta_title": "My Page Title",
  "meta_description": "A description for search engines"
}

Writing Data

Use the plain sub-field names directly — no prefix needed:

{
  "meta_title": "My Page Title",
  "meta_description": "A description for search engines"
}

Nesting

Collapsible can be nested inside other layout wrappers (Tabs, Row) and inside Array/Blocks sub-fields at arbitrary depth. All nesting combinations work — see the Layout Wrappers section for details and examples.

Depth limit: The admin UI caps layout nesting at 5 levels. The data layer has no limit.

Admin Rendering

Sub-fields are rendered inside a collapsible section with a toggle header. The section starts collapsed by default (admin.collapsed = true). Set admin.collapsed = false to start expanded. Clicking the header toggles visibility. This is useful for grouping related fields that don’t need to be visible at all times (e.g., SEO settings, advanced options).

Comparison with Group and Row

FeatureGroupRowCollapsible
Column prefixgroup__subfieldnonenone
API nestingnested objectflatflat
Admin layoutcollapsible fieldsethorizontal rowcollapsible section
Use caseNamespaced fieldsSide-by-side fieldsToggleable sections