Skip to content

select

select<TFieldMeta>(options?): SelectField<TFieldMeta>

Defined in: packages/core/src/fields/select/config.ts:60

Creates a select field with all defaults applied.

Select fields store an array of chosen option values — suitable for status labels, categories, tags, or any enumerable choice set. Set hasMany: false to restrict to a single selection.

Accepts SelectFieldInput (all optional) and returns SelectField with all defaults applied.

Defaults applied:

  • label"" (inferred from the field key by defineCollection)
  • requiredfalse
  • defaultValue[]
  • options[]
  • hasManyfalse
  • admin.hiddenfalse
  • admin.readOnlyfalse
  • admin.position"main"
  • admin.width"full"
  • admin.cellAlignment"left"

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

SelectFieldInput<TFieldMeta>

Select field configuration. All properties are optional.

SelectField<TFieldMeta>

Resolved select field definition with all defaults applied.

import { select, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Single-select status field
status: select({
required: true,
options: [
{ label: "Draft", value: "draft" },
{ label: "Published", value: "published" },
],
}),
// Multi-select tag field
tags: select({
hasMany: true,
options: [
{ label: "News", value: "news" },
{ label: "Tutorial", value: "tutorial" },
{ label: "Release", value: "release" },
],
}),
}
})