---
title: "Recipe: a grouped form"
description: "An entry or settings form: a grouped list with a text field, a quantity, a switch and a date picker."
modificationDate: "2026-11-14"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: a grouped form

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/grouped-form: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

An entry or settings form: a grouped list with a text field, a quantity, a switch and
a date picker. Save is disabled until the form is valid, saying why.

```prompt Add a grouped form
Add an entry or settings form to the Exact app in this folder: a grouped list of fields, with Save disabled until the form is valid. Use https://github.com/expo/exact/blob/main/docs/recipes/grouped-form.md as the source for each step. The Exact checkout has the same page at docs/recipes/grouped-form.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not name the fields and what makes the form valid, propose them from the app's data and ask me before you write code.
3. In app.contract, make the form a `list listStyle="inset-grouped"` of `section`s, a `state` per field. Use the platform's controls and leave their look unsaid: `input` for text, `input type="number" min max step` for a quantity, `input type="checkbox" switch` for a switch, `input type="date"` for a date, and `select` for a menu. A number field's value is text: read it with `parseNumber`.
4. Put Save in the header, disabled while the form is not valid, and say why in the section's `footer`. Give the last field `submit=save`, so Enter saves.
5. In app.test.contract, add a test that Save is disabled and the reason shows, then that a valid entry enables Save, and that Enter saves.
6. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 7) and report it; do not keep trying.
7. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
8. Tell me the fields and the rule for a valid form, what the tests and verify reported, and the launch command for each target platform.
```

```contract
routes nav
  home "/"

component Profile
  state name = ""
  state qty = "1"
  state reminders = true
  state birthday = ""
  state saved = false
  derive nameHint = name.trim() == "" ? "Enter your name to save." : ""
  action editName(v: string)
    name = v
  action editQty(v: string)
    qty = v
  action setReminders(on: bool)
    reminders = on
  action setBirthday(v: string)
    birthday = v
  action save
    if nameHint == ""
      saved = true
  view
    main navigationKey=`${top(nav).id}` testId="app" width="100%" height="100%"
      for e in stack(nav) key=e.id
        column navigationKey=`${e.id}` navigationScroll="form" position="absolute" inset=0
          display="flex" flex-direction="column"
          header display="flex" align-items="center" padding="8px 16px"
            text "Profile" role="heading" aria-level=1 flex=1
            button press=save buttonStyle="filled" disabled=(nameHint != "") testId="save"
              text "Save"
          list id="form" appearance="auto" listStyle="inset-grouped" flex=1 min-height=0
            section
              row
                input value=name input=editName submit=save placeholder="Name" aria-label="Name"
                  autocomplete="name" autocapitalize="words" testId="name" flex=1 min-width=0
              footer
                text nameHint testId="name-hint"
            section
              row
                text "Quantity"
                input type="number" value=qty input=editQty min=1 max=99 step=1 aria-label="Quantity" testId="qty"
              row
                text "Reminders"
                input type="checkbox" switch checked=reminders change=setReminders aria-label="Reminders" testId="reminders"
              row
                text "Birthday"
                input type="date" value=birthday change=setBirthday aria-label="Birthday" testId="birthday"
```

```contract-test
test "Save waits for a name, saying why; Enter saves"
  expect disabled "save"
  expect text "name-hint" == "Enter your name to save."
  type "name" "Ada"
  expect enabled "save"
  expect text "name-hint" == ""
  type "name" key "Enter"
  expect state saved == true
```

- Leave a field in a grouped row unsaid: each platform draws its own, as it does a switch, a
  date picker and a menu (`select` of `option "Metric" value="metric"`).
- A quantity from 1 to 99 is `input type="number" min=1 max=99 step=1`: the platform draws its
  stepper, which adds `step`; the field stays editable and its `value` is text (`parseNumber` it).
- A `text` and a control in a row are a title and its accessory; any other is a flex row.
  Save is disabled until valid, the reason in the section's `footer`; red under a field is a
  refusal the data sent back ([after a write](https://exact.expo.dev/recipes/after-a-write.md)), kept until a Save succeeds.
  `submit=save` makes Enter save (no `form`).
