Form View

A public form made from a collection's fields, with validation and a thank-you state.

Report a bug

Tell us what broke. We triage new reports every morning.

Fields marked with an asterisk are required.

One line, like a headline: what you did and what happened.

How bad is it? (required)

Which customer hit it?

Leave it empty if you found it yourself.

Never submit passwords or payment details through this form.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/form-view

Usage

import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { type FormConfig, type Item, type Property, Value } from "./ui/uicontext/components/domain/Record.ts"import { FormView } from "./ui/uicontext/components/kit/FormView.ts"
const Message = UiSchema.TaggedEnum({	RequestedSubmit: { request: Schema.String, values: Schema.Record(Schema.String, Value) },})const form: FormConfig = {	title: "Request a feature",	fields: [{ key: "title", label: "What would help?", required: true }, { key: "priority" }],	submitLabel: "Send request",}// Create the record, then answer with { _tag: "Accepted" | "Refused", request } as `outcome`.export const FeatureRequest = (	h: Html.H<typeof Message.Type>,	records: ReadonlyArray<Item>,	fields: ReadonlyArray<Property>,	outcome: Outcome | null,) =>	FormView(h, {		props: { label: "Request a feature", records, fields, view: { layout: "form", form }, outcome },		onEmit: {			RequestedSubmit: (response) => Message.RequestedSubmit(response),			RequestedEdit: () => undefined,			RequestedOpen: () => undefined,			RequestedCreate: () => undefined,			RequestedAction: () => undefined,			RequestedReorder: () => undefined,			RequestedView: () => undefined,			Selected: () => undefined,		},	})

Examples

A refused response

Send it with a date in the past: the app refuses, and the form keeps the answers and says why.

Book a fix

Ask the support team to fix something by a date.

Fields marked with an asterisk are required.

For which customer? (required)

Pick a date after today.

Never submit passwords or payment details through this form.

Questions that depend on an answer

Pick "Something's broken" and the form asks for steps and a browser; pick Billing and it asks for your plan.

Contact support

Tell us what you need. A person reads every request, usually within a working day.

Fields marked with an asterisk are required.

What do you need help with? (required)

One line, like a subject.

Never submit passwords or payment details through this form.

Closed

A form that takes no responses for now, with the reason in place of its questions.

Beta sign-up

Try the new triage view before everyone else.

This form is closed

The beta is full. Sign-ups open again in January.

API reference

Props

FormView props
NameTypeDefaultDescription
agentIdstringform:<label>This form's id for agents, unique on the page; form:<label> by default
labelrequiredstring—The form's accessible name, and its title when the view has no form config
recordsrequiredItem[]—The collection's records; a form doesn't show them, but takes them like every record view
fieldsrequiredProperty[]—The collection's fields; the form asks for the ones its view lists
viewViewInput—The view; view.form says what the form asks
outcomeOutcome | null—The app's answer to the latest RequestedSubmit; null until there is one
localestring—The locale numbers and dates are formatted in; the browser's by default

Events

FormView events
EventPayloadDescription
RequestedEdit{ request: string; item: string; key: string; value: Value }A value the person changed; answer through outcomes with the same request
RequestedOpen{ item: string }Open the record's page
RequestedCreate{ group?: string; title?: string; values?: Record<string, Value> }A new record, in the group it was added from ("" for the empty group)
RequestedAction{ action: string; items: string[] }One of the view's actions, on these records
RequestedReorder{ item: string; before: string | null }Move item before before, or last when it's null
RequestedView{ view: View }The person changed how the view shows records (its sort, grouping, widths); pass it back as view
Selected{ items: string[] }The selection changed
RequestedSubmit{ request: string; values: Record<string, Value> }One response: every asked value and the form's defaults; answer through outcome

Slots

share

Agent actions

What agents can do with FormView
ActionDescription
ChangedFieldFill one field: { field: its key, value }. Text, email, URL, phone and date take a string; number and rating a number; checkbox a boolean; select and person one choice value; multi-select, relation and attachment a list.
SubmittedFormSubmit the response. Errors, if any, show in the snapshot's errors.
ClickedSubmitAnotherStart another response after one went in.

Accessibility

  • Each field ties its label, help and error to the control, and marks it aria-required and aria-invalid.
  • Choice cards and stars are radio groups: one Tab stop, and the arrow keys, Home and End move the choice.
  • A field shows its error once you leave it. Submitting with errors lists them in an alert and moves focus to the first one; a refused response keeps what was typed.
  • Agents fill fields by key, submit, and read any errors back from the page.

Source