Field type
repeater
A list of rows in the sidebar: each row a small form (its fields), with Add, remove and drag to reorder. Stored as an array of rows. For like items with a few simple values (stats, logos, links). Not the same as the <repeater> marker, which makes child blocks on the canvas.
Type: repeater · Stored attribute type: array
Stored value
array of objects — one per row, each { _id, ...sub-field values } (_id is stable across reorders)
Supports
- Sub-fields of any registered control type (text, textarea, image, url, icon …)
- min / max rows, addButtonLabel, collapsedTitle (the sub-field shown in a row's header)
- Typing a text sub-field on the canvas (data-gcb-row / data-gcb-subfield)
Config options
| Option | Type | Default | Description |
|---|---|---|---|
fields | array | The controls of ONE row, each with its own attributeKey (unique within the row). | |
addButtonLabel | string | The Add button's label. | |
collapsedTitle | string | Which sub-field names a row in its header. | |
min / max | number | Row limits (max null = unlimited). |
Gotchas
- The
<repeater allowedblocks=... />marker in render.php is a different thing: it makes CHILD BLOCKS on the canvas (rich items, each its own block). Use the field for simple rows, the marker for rich items — see AGENTS.md "Lists: four ways". - In render.php read rows defensively:
(array) ($attributes[$key] ?? []), and each row(array) $row— WordPress can hand an empty value over as an object.
Example
{
"id": "stats", "attributeKey": "stats", "type": "repeater", "label": "Stats",
"addButtonLabel": "Add stat", "collapsedTitle": "value",
"fields": [
{ "id": "value", "attributeKey": "value", "type": "text", "label": "Figure" },
{ "id": "label", "attributeKey": "label", "type": "text", "label": "Caption" }
],
"default": [ { "_id": "s1", "value": "100+", "label": "Cars in stock" } ]
}A list of rows in the sidebar
type: "repeater" stores an array of rows; each row is shaped by fields. The sidebar shows the rows with Add, remove and
drag to reorder. Working example: examples/blocks/lists-stats (block.fields.json and render.php).
Not the <repeater> marker
The marker printed in render.php — <repeater allowedblocks='["gcb/card"]' addbuttonlabel="Add card" /> — makes child
blocks on the canvas instead: each item is its own block with its own fields. Working example:
examples/blocks/demo-feature-trio with demo-feature-item. Which to use: AGENTS.md, "Lists: four ways, and which to
choose".
Every field also takes the keys common to all fields.