Skip to main content
HydroGo
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

KeyApplies toMeaning
idallIdentifier, same pattern as the type id. Used as the JSON key.
labelallLabel in forms and list columns.
kindallOne of the kinds below.
requiredallThe record cannot be saved without a value.
uniqueallNo two records may share the value. Not combinable with localized.
optionsselectList of allowed values.
torelationId of the target content type.
manyrelationtrue lets one record link to several targets.
min, maxnumberInclusive numeric bounds.
listallShow as a column in the admin list. List columns are sortable by clicking the heading.
searchabletext, textarea, richtext, selectInclude in the admin list search box and the public API ?search=.
filterabletext, textarea, select, numberAdd a filter to the admin list and allow ?filter[field]= on the public API.
localizedtext, textarea, richtext, mediaKeep one value per site locale. See Localized fields.

Field kinds

KindStoresAdmin controlAPI value
textShort stringSingle-line inputString
textareaLong plain textMulti-line inputString
richtextFormatted textRich text editorHTML string
numberNumberNumber inputNumber
booleanTrue or falseCheckbox or switchBoolean
dateCalendar dateDate pickerDate string
datetimeDate and timeDate and time pickerTimestamp string
selectOne of optionsDropdownString
mediaReference to a media itemMedia library pickerMedia reference
relationReference to another recordRecord pickerRecord 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, max and options are enforced by the server on every write, from the admin and the API alike.
  • Validation failures answer 422 with a fields map, for example {"title": "required"}. See Errors.
  • A field may not be both localized and unique, searchable or filterable; 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.