Reference › Fields
Docs/Reference/Fields

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).
uniqueWithinstring | string[]With unique or on a slug: sibling fields (e.g. parent, tenant); values only differ among documents with the same values there.
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.
customTypestringSet by Easy CMS for fields of an added type (e.g. color); don't set it yourself.

admin

OptionType
componentAdminComponentA Web Component instead of the input. Admin components
afterAdminComponent[]Components shown below the field.
cellAdminComponentShows the value in the list's column, e.g. a color swatch.
descriptionLabelHelp below the field.
width'1/4' | '1/3' | '1/2' | '2/3' | '3/4' | 'full'Its share of a row (admin.layout). Default: an equal share.
conditionFieldConditionShown only when sibling fields match, e.g. { field: 'linkType', equals: 'external' }; also notEquals, in, exists, and, or, not. A hidden field isn't required. The admin
columnboolean | ({ user, context }) => booleanA column of the list at first (each user can change it).
allowCreatebooleanRelationships: offer to create the related document in place. Default true.
defaultValue({ user, context }) => unknownThe value a new document's form starts with, per user, e.g. from the request's context.

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, or an array with hasManyhasMany, mimeTypes
relationshipid(s) of documentsto, hasMany, minRows, maxRows
arrayrows with id and sub-fieldsfields, minRows, maxRows
groupan objectfields
blocksrows of several kinds, with blockTypeblocks, minRows, maxRows

Packages add more types, e.g. color from @easy-cms/fields: see Custom field types.

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.

upload

OptionType
hasManybooleanSeveral files, in the order editors arrange (a gallery); the value is an array.
minRowsnumberWith hasMany: the fewest files.
maxRowsnumberWith hasMany: the most files.
mimeTypesstring[]Allowed file types, e.g. ['image/*']; the picker offers only these and saving checks them.

relationship

OptionType
tostringRequired. Slug of the target collection.
hasManybooleanSeveral documents; the value is an array.
minRowsnumberWith hasMany: the fewest documents.
maxRowsnumberWith hasMany: the most documents.
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.