Browse all documentation

Select field

Define a typed single or multiple choice with stable stored values and translated author labels.

Use field.Select when a value must come from a finite set. It renders a dropdown for one choice and a multi-select when you add field.Multiple(). Generated TypeScript narrows input and output to the configured string values instead of a free-form string.

In the admin

An open multiple Status select in the Ridu admin showing In review and Published as selected choices.

The menu displays labels; stored and generated values use the configured choice keys.

Smallest working example

content/posts.go
field.Select(
  "status",
  field.OneOf("draft", "review", "published"),
  field.Default("draft"),
)

OneOf derives labels from the stored values. Use Choices when author-facing labels should differ:

content/posts.go
field.Select(
  "visibility",
  field.Choices(
    field.Choice{Value: "public", Label: "Everyone"},
    field.Choice{Value: "members", Label: "Signed-in members"},
  ),
)

Values are stable data; labels and LabelTranslations are presentation. Changing members to registered is a data/API migration, while changing its label is not.

Multiple choices

content/posts.go
field.Select(
  "channels",
  field.OneOf("web", "email", "social"),
  field.Multiple(),
  field.DefaultChoices("web", "email"),
)

Multi-selects store an ordered list of unique configured values. Use DefaultChoices rather than the scalar Default. Radio cannot be multiple.

Validation, queries, and localization

At least one non-empty unique choice is required. Defaults must be in the choice list. Select also supports Required, localization, indexing/uniqueness where appropriate, conditions, and common admin options. Query single choices with scalar equality/inequality and multi-selects with the generated list-aware operators. Localizing the field stores different selected values per content locale; translating choice labels alone uses Choice.WithLabelTranslations.

Common mistakes

  • Do not use labels as API values. Submit the exact Value string.
  • Adding a choice is additive; removing or renaming a value requires a migration for existing data.
  • Use Relationship when choices are managed documents rather than a fixed list compiled into config.

See field.Select, field.Choices, and field.Multiple.