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
- Go to Models.
- Open the model you want to change.
- Select Fields.
- Select Add field.
- Select the Group card.
- In API name, enter a name in lowerCamel case, for example
hero.
Add sub-fields and save
- Select Add sub-field.
- Rename the new sub-field, for example
heading. Repeat this step and the previous one for each sub-field. - Select Add field.
- 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….
- Open the model.
- Select Fields.
- Select Add field.
- Select the Component card.
- In Component, select the component to store.
- Select Add field.
- 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.
- Open the model.
- Select Fields.
- Select Add field.
- Select the Dynamic zone card.
- Select the components that editors can add, using the checkboxes.
- Select Add field.
- 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.