Skip to content

Widgets and formatters

A compound's Manage form display selects shared sub-field widgets; Manage display selects formatters. New sub-fields use their Drupal field plugin's defaults. Compatible field modules supply additional choices. Try Address, Media Library and references.

Override one host field

On the host content type's Manage form display, expand the compound widget's settings and use Sub-widgets for this field. On Manage display, use Sub-formatters for this field. Unchanged settings follow the shared defaults; overrides affect only this field instance.

Drag the sub-field rows, or use Show row weights, to give this field instance its own sub-field order. While the order matches the shared display, the field keeps following it; once you reorder, the field keeps its own order, and sub-fields added to the compound later appear after the others. Drag the rows back into the shared order to follow the shared display again.

Under Sub-field layout, choose Stacked or Inline columns and set widths for the latter.

Each item of a host field is wrapped in a collapsible details element that starts open. Under Item wrapper choose Collapsible (details), Fieldset or No visual wrapper (div). With details, this setting applies:

  • Open by default: turn it off to start items closed. On a field that holds several items, only the item added with Add another item (the blank row of a field with an unlimited number of values) opens. The slots of a field with a fixed number of values follow Open by default and the threshold.

A field that holds one item shows its own label as the item title. Its details element opens natively, with no script, and opens by itself when it holds a validation error. The settings below apply only to details on a field that holds several items:

  • Start closed from this many items: with Open by default off, items start closed once the field holds at least this many filled items. 0 starts every item closed.
  • Auto-collapse: shown only with details and Open by default off. Opening an item closes the other items. An item with a validation error is never closed this way. After Add another item the new item opens and the others close. The Collapse all / Edit all button overrides it.

On a field that holds several items, details items also get a Collapse all / Edit all button. On a field with an unlimited number of items it sits above the Remove buttons. On a field with a fixed number of items, which has no Remove buttons, it sits next to the field label, right-aligned. It needs JavaScript. It is also present with Auto-collapse: a click overrides Auto-collapse, and the next item you open by hand closes the others again (items with validation errors stay open). Collapse all also closes items with validation errors, since you asked for it.

With details on a field that holds several items, Item summary sub-field makes the item title show the live value of one single-value sub-field (text, number, email, telephone or list), shortened to Item summary maximum length characters (60 by default, between 10 and 255; the field only shows while a sub-field is chosen). It falls back to the plain item title while the value is empty and is shown only to editors who may view and edit that sub-field. Fields that hold one item, and the fieldset and div wrappers, ignore these two settings.

The plain item title is the field label and the item's number, such as "Cards (value 2)". The number follows the row order: it updates when you drag an item to a new place and after the form reloads items in their new order.

An item with a validation error opens by itself. Each item keeps its open or closed state when you add, remove or reorder items.

The widget summary on Manage form display lists every setting that applies to the field, including the ones left at their defaults. A setting that another choice switches off, such as Auto-collapse while items open by default, or any details setting with a fieldset, is left out.

Upgrading from 1.x-dev

The default item wrapper changed from a fieldset to an open details element, which changes the markup and any theme CSS or test locators aimed at fieldset. Choose Fieldset to keep the previous markup.

The inline layout keeps its columns inside details in Claro, Gin, Olivero and the default admin theme. Stark and Stable 9 render no inner wrapper, so inline columns stack inside details there.

Enable Compound Field: Layout Builder sub-field blocks to arrange individual sub-fields on the host layout.