Help topics

Reuse components and group fields

Group related fields in an object, or store one of several reusable components in a single field, so your entries keep a flexible layout.

Before you start

  • You need the Administrator role to change models.
  • For a component field or a dynamic zone, create at least one component first, from New component on the Models page.

Group fields

A group stores its sub-fields under one name in each entry.

Add the group field

  1. Go to Models.
  2. Open the model you want to change.
  3. Select Fields.
  4. Select Add field.
  5. Select the Group card.
  6. In API name, enter a name in lowerCamel case, for example hero.

Add sub-fields and save

  1. Select Add sub-field.
  2. Rename the new sub-field, for example heading. Repeat this step and the previous one for each sub-field.
  3. Select Add field.
  4. Select Save changes.

Each new sub-field starts as a text field with a maximum length of 255 characters.

Your entries store the grouped values under the group name:

"hero": { "heading": "Spring sale", "sub": "Up to 40% off" }

Add a component field

A component field stores one component from your list of components.

Important: Choose a component before you select Add field. Otherwise the app shows the error "Choose a component" and does not add the field. If no component exists yet, the Component list shows only Choose….

  1. Open the model.
  2. Select Fields.
  3. Select Add field.
  4. Select the Component card.
  5. In Component, select the component to store.
  6. Select Add field.
  7. Select Save changes.

Add a dynamic zone

Use a dynamic zone when editors should stack several blocks.

Note: A dynamic zone stores a list of components, and each item must name one of the components the field allows.

  1. Open the model.
  2. Select Fields.
  3. Select Add field.
  4. Select the Dynamic zone card.
  5. Select the components that editors can add, using the checkboxes.
  6. Select Add field.
  7. Select Save changes.

Each item in a dynamic zone names its component in __component:

"blocks": [{ "__component": "card", "title": "Our story" }]

Result

An entry that holds these fields keeps the group, component and dynamic zone values in its data.

Errors

  • Component field with no component chosen: the app shows "Choose a component" and does not add the field.
  • Component does not exist: a field or dynamic zone that names a missing component fails to save with "component NAME does not exist". Create the component, or choose an existing one.
  • Too many levels: a group can contain groups, up to 8 levels deep. A deeper structure fails with "fields nest at most 8 levels". Flatten the structure or split it into components.