Help topics

Add and configure fields

A field holds one value of each entry, such as a title or a price. Its options decide how the editor, the API and filters treat that value.

Before you start

  • You need a WordPress account with the administrator role. Only administrators can change models.
  • You need a model to add the field to.

Add a field

Set the options in the field dialog before you select Add field. See Set field options.

Steps

  1. Go to Models.
  2. Select the model.
  3. Select the Fields tab.
  4. Select Add field. The Add a field dialog opens.
  5. Select a field type, for example Number for a price. Relation opens its own dialog.
  6. Optional: In Label, enter the name the editor shows. If you leave it empty, the editor shows the API name in title case.
  7. In API name, enter the key the API uses, for example price or coverImage. Start with a lowercase letter, and use only letters and digits. Use up to 64 characters.
  8. Select Add field.
  9. Select Save changes. The app shows the message Saved as version with the version number.

Result: the field appears in the Fields list with its badges. See Field badges.

Set field options

The field dialog has three tabs: Basic, Validation and Filtering & privacy. Not every option appears for every type.

Basic

  • Required: entries cannot be saved without a value.
  • Default value: used when a new entry leaves this field empty. Not shown for Group, Component, Dynamic zone, JSON and Media fields, or for secret fields.
  • Use as title: shown as the entry name in lists, links and search. Available for Text and Options fields in models, when the field is not secret.
  • Options (for Options fields only): type an option and press Enter or a comma. Renaming an option creates a new value. Entries that already have the old value keep it.

Validation

  • Text and Rich text: Minimum length and Maximum length. New text fields start with a maximum length of 255.
  • Number: Minimum, Maximum and Whole numbers only, which refuses decimals.
  • List and Dynamic zone: Minimum items and Maximum items. A list used as a filter can set a maximum of 64 items.
  • JSON: Maximum size in bytes.
  • Other types show: "This field type has no extra validation."

Filtering & privacy

  • Filter by this field: available for Text, Number, Boolean, Date & time, Options and Media fields, and for lists of these. It lets lists be filtered or sorted by this field quickly. Each save does more work. Text fields longer than 256 characters and multi-line text fields cannot be filtered.
  • Searchable: available for Text and Rich text fields that are not secret. It includes the field in full-text search.
  • Unique: available for filterable fields, except lists. The toggle adds a single-field unique rule to the model. See Add indexes and unique rules.
  • Hidden: only administrators see the field in the API. With Morphic Pro, people with full access see it too. Other readers do not get its value.
  • Secret (Text fields only): Hashed stores a value that can be checked but never read back. Sealed stores an encrypted value that people with full access can read. Sealed needs Morphic Pro. A secret field cannot be filtered or searched.

Group fields

A Group field holds several sub-fields together, like an address.

Steps

  1. Select Group as the field type, as in Add a field.
  2. Select Add sub-field. The app names the sub-field field1, then field2, and so on. A sub-field starts as text with a maximum length of 255.
  3. Enter a Label for each sub-field.
  4. Optional: To remove a sub-field, select Remove (trash icon).

See Reuse components and group fields for nesting and components.

Field badges

Each row in the Fields list shows badges in this order: Required, Title, Filter, Search, Unique, Hidden, and Sealed or Hashed for secret fields.

Errors

These messages appear in the field dialog when you select Add field or Done.

  • "The API name starts with a lowercase letter and uses only letters and digits, like coverImage": the API name has a character that is not allowed, a leading digit or more than 64 characters. Change the API name.
  • "id is reserved; choose another API name": the API names id, parent, root, created, updated and rev are used by the system. Choose another name.
  • "There is already a field called <name>": another field or relation in this model has the same API name. Choose another name.
  • "Add at least one option": an option field has no options. Add an option.
  • "Choose a component": a component field has no component selected. Choose a component.

When a model is saved through the API, the server reports these errors instead:

  • "field names are lowerCamel": the name does not match the API name rule. Change the name.
  • "id is a system field": a system name is used at the top level of a model.
  • "an enum lists its values": an option field has no values.
  • "component <name> does not exist": the component name is wrong or the component was not created.
  • "an ordered index needs max of at most 256; use fulltext": a filter is set on a text field longer than 256 characters. Lower the maximum length or make the field searchable instead.

If you rename a field, the app asks you to confirm Save and rename. Existing entries are upgraded automatically. API clients see the new name.