Save as modes
Save as decides what is written to the entry when an editor picks an item. It is a trade-off: some modes keep working when the source is reordered, others when an item is renamed.
Which modes fit which source
| Source data | Example fields | Allowed modes |
|---|---|---|
| List of strings | List, Checkboxes | value, index |
| List of objects | Grid, Replicator | index, id, object_key, object |
| Object (key → value) | Array | key, value |
| Assets | Assets | value (recommended), index |
If Save as doesn't fit the source data, the field shows a warning that names the modes to use. See Troubleshooting.
The modes
| Mode | save_as | Saved value | Survives reordering | Survives renaming |
|---|---|---|---|---|
| Key | key | The key of an Array item, e.g. express | yes | if the key is unchanged |
| Value | value | The string, Array value or asset ID | yes | no |
| Index | index | Position in the source, e.g. 2 | no | yes |
| Item ID | id | The row's id, e.g. mf3k2a9x | yes | yes |
| Object key | object_key | The value of one key, e.g. alice@example.com | yes | if that key is unchanged |
| Object | object | A copy of the whole row | yes | depends on Object key |
Key
For keyed Array sources. Saves the array key (express). The label shown to editors is the value (Express shipping).
Value
For lists of strings, keyed Arrays and Assets. Saves the item itself: the string, the Array value, or the asset ID (assets::demo/photos/sunset.jpg).
If editors rename an item in the source (for example "Medium" to "M"), saved values that pointed at the old name no longer match.
Lists of objects
value is not allowed for Grid or Replicator sources. To store the whole row, use object.
Index
Saves the position (0, 1, 2…). Renaming an item is fine, but reordering, inserting or deleting items in the source makes the saved index point at a different item. Use it only for sources whose order doesn't change, or when "the item in this position" is really what you mean.
sizes_checkboxes: [0, 2] # multiple + indexItem ID
For Grid and Replicator sources. Saves the row's id, which Statamic gives each row. This is the most robust choice for rows: the selection survives reordering, renaming and edits to any field in the row.
- handle: editor
field:
type: field_item_relationship
source_field: team
save_as: id
option_label_source: '`${o.name} — ${o.role}`'Object key
For Grid and Replicator sources. Saves the value of the key you set in Object key (object_key, dot notation allowed). Pick a key that is unique and doesn't change, such as an email address or a slug.
- handle: reviewers
field:
type: field_item_relationship
source_field: team
save_as: object_key
object_key: email
multiple: true
max_items: 3Object
Saves a copy of the whole row in the entry.
- With Object key set, the row is matched again by that key, both in the control panel and in templates. The
firtag returns the current row from the source, and falls back to the saved copy if the row is gone. - Without an Object key, the control panel matches on the exact content, so any edit to the row loses the selection. The tag returns the saved copy.
- handle: spotlight
field:
type: field_item_relationship
source_field: team
save_as: object
object_key: name
input_type: button_group
option_label_source: nameWhich one should I pick?
- Assets:
value. - List of strings:
valueif items are rarely renamed,indexif they are rarely reordered. - Keyed Array:
key. - Grid / Replicator rows:
id. Useobject_keyif you want a readable value in the content file (such as an email).
Labels with string literals
The label doesn't affect what is saved, but it is set next to Save as. Option label source takes a key (dot notation allowed), or a JavaScript template literal in back ticks, where o is the item:
option_label_source: '`${o.city}, ${o.country}`'

`${o.name} — ${o.role}`