Skip to content

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 ​

OptionType
namestringRequired. A JavaScript identifier; unique among its siblings.
typesee typesRequired.
labelstring | { en, th }Default: the name, humanized.
requiredbooleanMust have a value (not checked while saving a draft).
uniquebooleanNo two documents share the value (top-level fields).
indexbooleanAdds a database index.
defaultValuethe field's valueUsed when a document is created without it.
validate(value, { data, operation }) => true | stringCustom check; may be async.
access{ read?, update? }Field-level access.
hiddenbooleanStored, but never returned nor accepted as input.
localizedbooleanOne value per locale (needs localization).
position'sidebar'Shown in the edit page's side column (top-level fields).
adminFieldAdminAdmin components; see below.

admin ​

OptionType
componentAdminComponentA Web Component instead of the input. Admin components
afterAdminComponent[]Components shown below the field.

An AdminComponent is a tag name starting with ecms-, or { tag, props }.

Types ​

TypeValueExtra options
textstringminLength, maxLength
textareastringminLength, maxLength
emailstring (lowercase)
numbernumbermin, max
booleanboolean
dateISO 8601 string
selectan option, or an array with hasManyoptions, hasMany
slugURL-safe string, uniquefrom
jsonany JSON
richTextTiptap JSONsee Rich text
uploadid of a media document
relationshipid(s) of documentsto, hasMany
arrayrows with id and sub-fieldsfields, minRows, maxRows
groupan objectfields
blocksrows of several kinds, with blockTypeblocks, minRows, maxRows

text and textarea ​

OptionType
minLengthnumberFewest characters.
maxLengthnumberMost characters; the admin stops typing there.

number ​

OptionType
minnumberSmallest value.
maxnumberLargest value.

select ​

OptionType
options(string | { label, value })[]Required. The choices; label may be { en, th }.
hasManybooleanPick several (checkboxes); the value is an array.

slug ​

OptionType
fromstringA sibling text field to make the slug from when it is empty.
uniqueWithinstringA sibling field (e.g. parent): slugs only differ among documents with the same value there.

relationship ​

OptionType
tostringRequired. Slug of the target collection.
hasManybooleanSeveral documents; the value is an array.
filterOptions({ id, user, cms }) => Where | trueWhich documents it may point to; the admin's picker offers only these and saving checks them.

array ​

OptionType
fieldsField[]Required. The fields of each row.
minRowsnumberFewest rows.
maxRowsnumberMost rows.

group ​

OptionType
fieldsField[]Required. The fields inside.

blocks ​

OptionType
blocksBlock[]Required. The kinds of rows; see Block.
minRowsnumberFewest rows.
maxRowsnumberMost rows.

Block ​

OptionType
slugstringRequired. Stored in each row as blockType.
labels{ singular?, plural? }Names in the admin.
fieldsField[]Required. The block's fields.

Released under the MIT License.