Field types reference
Every field in a model has one kind. The kind sets the value an entry stores and the limits you can set. It also sets the message the API returns when a value is wrong.
To choose a kind, select Add field in a model's Fields tab. Relation is a separate dialog, not a kind: see Relations. On a node model, Relation also appears in the Add a field dialog.
Kinds
| Kind | Stored value | Limits you can set | Message when the value is wrong |
|---|---|---|---|
| Text | A string. Trimmed, lower-cased or slugged only when the field has the matching clean-up step. | Minimum length, Maximum length (default 255), Pattern, Clean up values | %s is text; %1$s is shorter than %2$s; %1$s is longer than %2$s; %1$s does not match %2$s |
| Rich text | A string of HTML. Sanitised with wp_kses_post unless the user can use unfiltered HTML. | Minimum length, Maximum length | Same as Text |
| Number | A number. Whole numbers only when Whole numbers only is on. | Minimum, Maximum, Whole numbers only | %s is a number; %s is a whole number; %1$s is below %2$s; %1$s is above %2$s |
| Boolean | true or false. | Default value: No default, On or Off | %s is true or false |
| Date & time | Unix milliseconds. A string in ISO 8601 or another format strtotime reads is converted to milliseconds. | None | %s is a time in Unix milliseconds or ISO 8601 |
| Date | Unix milliseconds at midnight UTC of the day given. | None | %s is a time in Unix milliseconds |
| Options | One string from the list of options. Compared as text. | Options (at least one option) | %1$s is one of %2$s, with the options comma-separated |
| A string, trimmed and lower-cased, with a pattern check. | Maximum length 254 | %1$s does not match %2$s, with the pattern | |
| Slug | A string, slugged, unique per model. | Maximum length 200 | Same as Text |
| Web address | A string that starts with http:// or https://. | Maximum length 2048 | %s is a web address starting with http:// or https:// |
| Color | A six-digit hex color such as #5b5bf6. Stored lower-case. | Maximum length 7 | %s is a color like #5b5bf6 |
| Video or embed | A string that starts with http:// or https://. | Maximum length 2048 | Same as Web address |
| Password | A one-way hash. You can verify it, never read it. A value left out of the request keeps the stored hash. | Secret: Hashed or Sealed (Sealed needs Morphic Pro) | <field name>: required when the field is required and no earlier value is stored |
| Media | The id of an attachment in the media library. | None | %s is a media library attachment id; %s is not a media library attachment |
| Gallery | A list of media ids, in order. | Up to 100 items | %s is a list; %1$s has more than %2$s items |
| File | The id of a media library attachment, like Media. | None | Same as Media |
| Multiple options | A list of values from the options list, shown as checkboxes. | Up to 20 items | %s is a list; each item is checked as an Options value |
| Link | An object with url, title and target (_self or _blank). | Address (web address rules, up to 2048); Label (up to 255); Opens in: _self or _blank | The sub-field path, like link.url |
| Location | An object with address (up to 500), lat (-90 to 90) and lng (-180 to 180). | Fixed ranges | The sub-field path, like location.lat |
| WordPress content | WordPress ids of posts, pages, users or terms. One id, or a list when the link is to several. | Links to: Posts, Pages, Users, another post type or a taxonomy; How many: One or Several; up to 500 links | %s holds WordPress ids; %s links to something that does not exist; %s links to more than 500 items |
| Group | An object with fields you define. | Fields you add to the group, up to 8 levels deep | %s is an object; %s nests too deep |
| Component | An object of one chosen component model. | Component | — |
| Dynamic zone | A list of objects. Each object names one of the allowed components in __component. | Blocks editors can add; Minimum items; Maximum items | %s is a list of components; each item names one of %s in __component |
Required fields
Turn on Required to refuse an entry without a value. The entry editor shows * next to the field name. It also shows the tip "Fields marked * are required." An empty value, or [] for a list, fails with <field name>: required.
Secret fields
For a Text field, use the Secret list to choose Hashed (stored as a hash) or Sealed (stored as a sealed value). Sealed fields need Morphic Pro. Without Pro, saving a sealed field fails with %s is a sealed field; sealing needs Morphic Pro. Secrets are redacted in history, webhooks and exports, and they cannot be filtered.
Nesting and size
Group fields can nest up to 8 levels. A deeper object fails with %s nests too deep. A WordPress content field can link to at most 500 items; more fails with %s links to more than 500 items.
Errors in WordPress boxes
When a model is attached to WordPress content, a wrong value shows a notice on the post screen. The notice reads "Morphic fields were not saved: " followed by the message.