Field reference
Every field option, checked against the types in @easy-cms/core by a test. For how fields look in the admin and how they are stored, see Fields.
Options of every field
| Option | Type | |
|---|---|---|
name | string | Required. A JavaScript identifier; unique among its siblings. |
type | see types | Required. |
label | string | { en, th } | Default: the name, humanized. |
required | boolean | Must have a value (not checked while saving a draft). |
unique | boolean | No two documents share the value (top-level fields). |
index | boolean | Adds a database index. |
defaultValue | the field's value | Used when a document is created without it. |
validate | (value, { data, operation }) => true | string | Custom check; may be async. |
access | { read?, update? } | Field-level access. |
hidden | boolean | Stored, but never returned nor accepted as input. |
localized | boolean | One value per locale (needs localization). |
position | 'sidebar' | Shown in the edit page's side column (top-level fields). |
admin | FieldAdmin | Admin components; see below. |
admin
| Option | Type | |
|---|---|---|
component | AdminComponent | A Web Component instead of the input. Admin components |
after | AdminComponent[] | Components shown below the field. |
An AdminComponent is a tag name starting with ecms-, or { tag, props }.
Types
| Type | Value | Extra options |
|---|---|---|
text | string | minLength, maxLength |
textarea | string | minLength, maxLength |
email | string (lowercase) | |
number | number | min, max |
boolean | boolean | |
date | ISO 8601 string | |
select | an option, or an array with hasMany | options, hasMany |
slug | URL-safe string, unique | from |
json | any JSON | |
richText | Tiptap JSON | see Rich text |
upload | id of a media document | |
relationship | id(s) of documents | to, hasMany |
array | rows with id and sub-fields | fields, minRows, maxRows |
group | an object | fields |
blocks | rows of several kinds, with blockType | blocks, minRows, maxRows |
text and textarea
| Option | Type | |
|---|---|---|
minLength | number | Fewest characters. |
maxLength | number | Most characters; the admin stops typing there. |
number
| Option | Type | |
|---|---|---|
min | number | Smallest value. |
max | number | Largest value. |
select
| Option | Type | |
|---|---|---|
options | (string | { label, value })[] | Required. The choices; label may be { en, th }. |
hasMany | boolean | Pick several (checkboxes); the value is an array. |
slug
| Option | Type | |
|---|---|---|
from | string | A sibling text field to make the slug from when it is empty. |
uniqueWithin | string | A sibling field (e.g. parent): slugs only differ among documents with the same value there. |
relationship
| Option | Type | |
|---|---|---|
to | string | Required. Slug of the target collection. |
hasMany | boolean | Several documents; the value is an array. |
filterOptions | ({ id, user, cms }) => Where | true | Which documents it may point to; the admin's picker offers only these and saving checks them. |
array
| Option | Type | |
|---|---|---|
fields | Field[] | Required. The fields of each row. |
minRows | number | Fewest rows. |
maxRows | number | Most rows. |
group
| Option | Type | |
|---|---|---|
fields | Field[] | Required. The fields inside. |
blocks
| Option | Type | |
|---|---|---|
blocks | Block[] | Required. The kinds of rows; see Block. |
minRows | number | Fewest rows. |
maxRows | number | Most rows. |
Block
| Option | Type | |
|---|---|---|
slug | string | Required. Stored in each row as blockType. |
labels | { singular?, plural? } | Names in the admin. |
fields | Field[] | Required. The block's fields. |