Fields

Fields

One question each. The key names the answer, the type decides the input.

A field

{
  key: "seats",
  type: "number",
  min: 1,
  label: "Seats",
}

key is the name the API uses for the answer. label is the question people read.

Labels in more than one language

A label is a plain string, or one entry per language. The form shows the person's language, then English, then any language the label has.

label: "Seats"
label: { km: "ចំនួនកៅអី", en: "Seats" }

Titles, hints, options and messages work the same way.

Types

TypeAsks for
texta short answer; long: true for a few lines
numbera number, with min, max and unit
date, timea day, or a time of day
select, radioone option
checkboxesseveral options
checkboxone tick box, true or false
yes-noa question that needs an answer
checklista list of items to confirm
filean attachment
listrows people add, each with its own fields
noticetext to read, no answer

A preset can add more. The service-form preset adds address, scan, consent and account.

Your own type

When none of these asks the question the way you need, write your own: a type file and an input component. Once registered, a form uses it like any other.

{ key: "service", type: "rating", label: "How was the inspection?" }

Your own field type builds this star rating from start to finish, with a live demo.