Who this is for. Content modellers and developers adding custom fields in the admin. After this page you can define a field with the input type, validation and default it needs, place it where authors expect it, and change it later without blocking their edits.
The settings of a definition
Custom fields are defined in the admin's Custom Fields screen. A definition holds these settings (the admin's labels in bold):
| Setting | What it does |
|---|---|
| The name | The key templates and the API use, such as jobTitle. Unique per entity, not across the account: a person and a product can each have a field called code. |
| Entity | The kind of record the field is added to, from the sixteen listed on Where custom fields attach. |
| Type | The input type, which decides the editor authors get and the shape of the value. |
| Label | What authors see on the form. "If not specified, the custom field name will be used": the admin then shows the name with each word capitalised. |
| Help, Info | Guidance for authors, shown with the field. |
| Required | "Control whether or not this field is required". See Validation. |
| Default | Default content, entered with the editor of the chosen type. See Defaults. |
Required and default belong to the definition, so they are the same for every record of the entity; neither can be set per record.
Choosing the input type
A custom field uses the same input types as layout areas, with the same categories and editors: see Category and editor decide behaviour. Only five categories are allowed: text, image, file, record and records. A custom field is never a component or a collection, and the Type list on the form offers only input types of those five categories.
The text category covers every text editor, so a custom field can be a plain text, a textarea, rich text, code, a colour, a number, a switch, a date or datetime, a select or a multiselect, as well as an image or a file. The Default setting offers the matching editor for each.
Where it appears on the form, and in what order
A record's custom fields are shown together, as one group on the record's admin form, each under its label, or its name with each word capitalised when it has no label.
There is no position setting. A definition has no order of its own, and the form lists an entity's fields in the order the database returns them, which in practice is the order they were created. The Custom Fields screen can sort its table by any column, but that changes the list on that screen, not the form. To control the order authors see, create the fields in that order. A field added later appears after the existing ones.
Validation
A custom field carries two kinds of validation, both from its definition:
- Required. A record must have a value for the field.
- The input type's own rules: a select's list of options, a maximum length, a regular expression. They are the rules a layout area of the same type applies; no validation rule is specific to custom fields.
Both are checked when the record that owns the value is saved, as part of that record's validation, not when the field is defined. A record without a value for a required field is refused with the message "Content for the custom field … is required", naming the field.
Making a field required later
Switching Required on for a field that already has records takes effect from each record's next save, not immediately: existing records are checked then, and that save fails until the field has a value, even when the author was changing something unrelated.