Content typesFields
Fields
Every field kind and flag, which flags apply to which kinds, and how each kind appears in the admin and the API.
Field keys
| Key | Applies to | Meaning |
|---|---|---|
id | all | Identifier, same pattern as the type id. Used as the JSON key. |
label | all | Label in forms and list columns. |
kind | all | One of the kinds below. |
required | all | The record cannot be saved without a value. |
unique | all | No two records may share the value. Not combinable with localized. |
options | select | List of allowed values. |
to | relation | Id of the target content type. |
many | relation | true lets one record link to several targets. |
min, max | number | Inclusive numeric bounds. |
list | all | Show as a column in the admin list. List columns are sortable by clicking the heading. |
searchable | text, textarea, richtext, select | Include in the admin list search box and the public API ?search=. |
filterable | text, textarea, select, number | Add a filter to the admin list and allow ?filter[field]= on the public API. |
localized | text, textarea, richtext, media | Keep one value per site locale. See Localized fields. |
Field kinds
| Kind | Stores | Admin control | API value |
|---|---|---|---|
text | Short string | Single-line input | String |
textarea | Long plain text | Multi-line input | String |
richtext | Formatted text | Rich text editor | HTML string |
number | Number | Number input | Number |
boolean | True or false | Checkbox or switch | Boolean |
date | Calendar date | Date picker | Date string |
datetime | Date and time | Date and time picker | Timestamp string |
select | One of options | Dropdown | String |
media | Reference to a media item | Media library picker | Media reference |
relation | Reference to another record | Record picker | Record id (array with many) |
Examples of each kind
YAML
fields:
- {id: title, label: Title, kind: text, required: true, unique: true, list: true, searchable: true}
- {id: summary, label: Summary, kind: textarea, searchable: true}
- {id: body, label: Body, kind: richtext}
- {id: price, label: Price, kind: number, min: 0, max: 10000, list: true, filterable: true}
- {id: in_stock, label: In stock, kind: boolean}
- {id: released_on, label: Released, kind: date}
- {id: starts_at, label: Starts at, kind: datetime}
- {id: status_note, label: Level, kind: select, options: [low, medium, high], filterable: true}
- {id: cover, label: Cover image, kind: media}
- {id: related, label: Related, kind: relation, to: recipes, many: true}Validation
required,unique,min,maxandoptionsare enforced by the server on every write, from the admin and the API alike.- Validation failures answer
422with afieldsmap, for example{"title": "required"}. See Errors. - A field may not be both
localizedandunique,searchableorfilterable; the loader rejects such files.
Changing a field's
kind after records exist is a data migration, not a rename. Add a new field, move the data, then remove the old one.