Collections and layout fields
Collections (repeating items), Section Builders (items of different kinds), Field Sets (grouped sub-fields) and Clones work in forms exactly as on edit screens: add, remove and reorder items, with every sub-field type inside.
How values arrive
A Collection is sent as a list of items, each keyed by sub-field key:
cafe[field_speakers][0][field_speaker_name] = Ada
cafe[field_speakers][1][field_speaker_name] = Grace
The server cleans the list (drops empty markers), validates every sub-field (Required, min/max items …) and saves all items in the same transaction as the rest of the form. Media sub-fields are checked per item.
From PHP (cafe_submit_dynamic_form()) pass the same structure:
cafe_submit_dynamic_form( 'new-event', [
'fields' => [
'speakers' => [
[ 'field_speaker_name' => 'Ada' ],
[ 'field_speaker_name' => 'Grace' ],
],
],
] );
Top-level fields may be given by name; sub-fields by key.
Notes
- Editing: items keep their identity (row IDs), so reordering and editing do not create new items.
- Without JavaScript, items cannot be added or removed (that needs the item buttons). The items that are on the page can still be filled in.
- After a failed submit without JavaScript, Collection items show their saved state (top-level fields keep what was typed).