---
title: "Formisch"
description: "Build forms in Solid using Formisch and Valibot."
---

This guide covers building forms with [Formisch](https://formisch.dev), the lightweight, schema-first, and fully type-safe form library for Solid. We'll create forms with the `<Field />` component, validate them with Valibot schemas, handle errors, and ensure accessibility.

## Demo

We'll build the following form. It has a simple text input and a textarea. On submit, we'll validate the form data and display any errors.

<Callout>
  **Note:** For the purpose of this demo, we have intentionally disabled browser
  validation to show how schema validation and form errors work in Formisch. It
  is recommended to add basic browser validation in your production code.
</Callout>

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupText,
  InputGroupTextarea
} from "~/components/ui/input-group"

const FormSchema = v.object({
  title: v.pipe(
    v.string(),
    v.minLength(5, "Bug title must be at least 5 characters."),
    v.maxLength(32, "Bug title must be at most 32 characters.")
  ),
  description: v.pipe(
    v.string(),
    v.minLength(20, "Description must be at least 20 characters."),
    v.maxLength(100, "Description must be at most 100 characters.")
  )
})

export default function BugReportForm() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      title: "",
      description: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Bug Report</CardTitle>
        <CardDescription>
          Help us improve by reporting bugs you encounter.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-demo" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["title"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-demo-title">
                    Bug Title
                  </FieldLabel>
                  <Input
                    {...field.props}
                    id="form-formisch-demo-title"
                    value={field.input ?? ""}
                    onValueChange={field.onInput}
                    aria-invalid={field.errors ? "true" : undefined}
                    placeholder="Login button not working on mobile"
                    autocomplete="off"
                  />
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
            <FormischField of={form} path={["description"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-demo-description">
                    Description
                  </FieldLabel>
                  <InputGroup>
                    <InputGroupTextarea
                      {...field.props}
                      id="form-formisch-demo-description"
                      value={field.input ?? ""}
                      placeholder="I'm having an issue with the login button on mobile."
                      rows={6}
                      class="min-h-24 resize-none"
                      aria-invalid={field.errors ? "true" : undefined}
                    />
                    <InputGroupAddon align="block-end">
                      <InputGroupText class="tabular-nums">
                        {(field.input ?? "").length}/100 characters
                      </InputGroupText>
                    </InputGroupAddon>
                  </InputGroup>
                  <FieldDescription>
                    Include steps to reproduce, expected behavior, and what
                    actually happened.
                  </FieldDescription>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-demo">
            Submit
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

## Installation

Install Formisch and Valibot:

```bash
npm install @formisch/solid valibot
```

Formisch supports Solid 2 through the `@formisch/solid/v2` entry point. It requires `solid-js` and `@solidjs/web` 2.x and the Solid 2 Vite plugin, `@solidjs/vite-plugin`. The API is the same as the Solid 1 entry; only the import path changes.

```ts
import { createForm, Field, Form } from "@formisch/solid/v2"
```

The examples show the submitted values in a toast. Add [Sonner](/docs/components/sonner/) and mount its `Toaster` once at the root of your app, or replace the `toast()` call with your own submit handling.

## Approach

This form leverages Formisch for headless, schema-first form handling. We'll build our form using the `<Field />` component, which gives you **complete flexibility over the markup and styling**.

- Uses Formisch's `createForm` primitive for form state management.
- `<Form />` component to wrap the native `<form>` element with submit handling.
- `<Field />` render-prop component for controlled inputs.
- Schema validation using [Valibot](https://valibot.dev).
- Type-safe field paths inferred from the schema.

## Form Methods

Formisch exposes form operations as **top-level functions** rather than methods on a form object. Import only what you need:

```ts
import { getInput, insert, reset, submit } from "@formisch/solid/v2"
```

Every method follows the same signature: the **first parameter is always the form store**, and the **second parameter (if necessary) is always a config object**.

```ts
// Read a field value
const email = getInput(form, { path: ["email"] })

// Reset the form with new initial values
reset(form, { initialInput: { email: "", password: "" } })

// Move an item in a field array
move(form, { path: ["items"], from: 0, to: 3 })
```

This design keeps the API flexible and consistent across all methods. You'll see the same `(form, config)` shape used throughout this guide for reading state (`getInput`, `getErrors`), writing state (`setInput`, `setErrors`), form control (`submit`, `validate`, `focus`), and array operations (`insert`, `remove`, `move`, `swap`, `replace`). See the [full methods reference](https://formisch.dev/solid/guides/form-methods/) for details.

## Anatomy

Here's a basic example of a form using the `<Field />` component from Formisch and the Solid UI `<Field />` component.

```tsx showLineNumbers {3-22}
<Form of={form} onSubmit={handleSubmit}>
  <FieldGroup>
    <FormischField of={form} path={["title"]}>
      {(field) => (
        <Field data-invalid={!!field.errors}>
          <FieldLabel for="form-title">Bug Title</FieldLabel>
          <Input
            {...field.props}
            id="form-title"
            value={field.input ?? ""}
            onValueChange={field.onInput}
            aria-invalid={field.errors ? "true" : undefined}
            placeholder="Login button not working on mobile"
            autocomplete="off"
          />
          <FieldDescription>
            Provide a concise title for your bug report.
          </FieldDescription>
          <FieldError errors={field.errors?.map((message) => ({ message }))} />
        </Field>
      )}
    </FormischField>
  </FieldGroup>
</Form>
```

<Callout>
  **Note:** Formisch ships its own `Field` component. To avoid a name clash with
  the Solid UI `Field`, the examples below import the Formisch one as
  `FormischField` and keep the Solid UI `Field` under its original name. In your
  own code you can alias either side; just be consistent.
</Callout>

## Form

### Create a form schema

We'll start by defining the shape of our form using a Valibot schema. Formisch infers all input and output types directly from this schema.

```tsx showLineNumbers title="form.tsx"
import * as v from "valibot"

const FormSchema = v.object({
  title: v.pipe(
    v.string(),
    v.minLength(5, "Bug title must be at least 5 characters."),
    v.maxLength(32, "Bug title must be at most 32 characters.")
  ),
  description: v.pipe(
    v.string(),
    v.minLength(20, "Description must be at least 20 characters."),
    v.maxLength(100, "Description must be at most 100 characters.")
  )
})
```

### Set up the form

Next, we'll use the `createForm` primitive from Formisch to create our form store. The schema is passed directly to `createForm`; there is no resolver step.

```tsx showLineNumbers title="form.tsx" {1-6,21-27}
import {
  createForm,
  Field as FormischField,
  Form,
  type SubmitHandler
} from "@formisch/solid/v2"
import * as v from "valibot"

const FormSchema = v.object({
  title: v.pipe(
    v.string(),
    v.minLength(5, "Bug title must be at least 5 characters."),
    v.maxLength(32, "Bug title must be at most 32 characters.")
  ),
  description: v.pipe(
    v.string(),
    v.minLength(20, "Description must be at least 20 characters."),
    v.maxLength(100, "Description must be at most 100 characters.")
  )
})

export function BugReportForm() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      title: "",
      description: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    // Do something with the validated form values.
    console.log(output)
  }

  return (
    <Form of={form} onSubmit={handleSubmit}>
      {/* ... */}
      {/* Build the form here */}
      {/* ... */}
    </Form>
  )
}
```

The `<Form />` component wraps a native `<form>` element. It calls `event.preventDefault()`, runs validation, and only invokes `onSubmit` when the data is valid. The `output` you receive is fully typed from the schema.

### Build the form

We can now build the form using the `<Field />` component from Formisch and the Solid UI `<Field />` component.

```tsx title="form.tsx"
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupText,
  InputGroupTextarea
} from "~/components/ui/input-group"

const FormSchema = v.object({
  title: v.pipe(
    v.string(),
    v.minLength(5, "Bug title must be at least 5 characters."),
    v.maxLength(32, "Bug title must be at most 32 characters.")
  ),
  description: v.pipe(
    v.string(),
    v.minLength(20, "Description must be at least 20 characters."),
    v.maxLength(100, "Description must be at most 100 characters.")
  )
})

export default function BugReportForm() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      title: "",
      description: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Bug Report</CardTitle>
        <CardDescription>
          Help us improve by reporting bugs you encounter.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-demo" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["title"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-demo-title">
                    Bug Title
                  </FieldLabel>
                  <Input
                    {...field.props}
                    id="form-formisch-demo-title"
                    value={field.input ?? ""}
                    onValueChange={field.onInput}
                    aria-invalid={field.errors ? "true" : undefined}
                    placeholder="Login button not working on mobile"
                    autocomplete="off"
                  />
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
            <FormischField of={form} path={["description"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-demo-description">
                    Description
                  </FieldLabel>
                  <InputGroup>
                    <InputGroupTextarea
                      {...field.props}
                      id="form-formisch-demo-description"
                      value={field.input ?? ""}
                      placeholder="I'm having an issue with the login button on mobile."
                      rows={6}
                      class="min-h-24 resize-none"
                      aria-invalid={field.errors ? "true" : undefined}
                    />
                    <InputGroupAddon align="block-end">
                      <InputGroupText class="tabular-nums">
                        {(field.input ?? "").length}/100 characters
                      </InputGroupText>
                    </InputGroupAddon>
                  </InputGroup>
                  <FieldDescription>
                    Include steps to reproduce, expected behavior, and what
                    actually happened.
                  </FieldDescription>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-demo">
            Submit
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

### Done

That's it. You now have a fully accessible form with client-side validation.

When you submit the form, the `handleSubmit` function will be called with the validated form data. If the form data is invalid, Formisch will populate `field.errors` for each invalid field and the UI will display them.

## Validation

### Client-side Validation

Formisch validates your form data using the Valibot schema you pass to `createForm`. There is no resolver: the schema is the single source of truth for both runtime validation and static types.

```tsx showLineNumbers title="form.tsx" {1,3-6,10}
import { createForm } from "@formisch/solid/v2"

const FormSchema = v.object({
  title: v.string(),
  description: v.optional(v.string())
})

export function ExampleForm() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      title: "",
      description: ""
    }
  })
}
```

### Validation Modes

Formisch separates the **first** validation from **subsequent** validations. You configure them with the `validate` and `revalidate` options on `createForm`.

```tsx showLineNumbers title="form.tsx" {3-4}
const form = createForm({
  schema: FormSchema,
  validate: "blur",
  revalidate: "input"
})
```

| Option       | Value       | Description                                                     |
| ------------ | ----------- | --------------------------------------------------------------- |
| `validate`   | `"submit"`  | Validate on form submission (default).                          |
| `validate`   | `"blur"`    | Validate when a field loses focus.                              |
| `validate`   | `"input"`   | Validate on every input change.                                 |
| `validate`   | `"initial"` | Validate immediately on form creation.                          |
| `revalidate` | `"input"`   | Revalidate on every input change after the first run (default). |
| `revalidate` | `"blur"`    | Revalidate on blur after the first run.                         |
| `revalidate` | `"submit"`  | Revalidate only on form submission.                             |

## Displaying Errors

Display errors next to the field using `<FieldError />`. Formisch returns errors as an array of strings, so map them to the shape `<FieldError />` expects. `<FieldError />` renders nothing while there are no errors. For styling and accessibility:

- Add the `data-invalid` prop to the `<Field />` component.
- Add the `aria-invalid` prop to the form control such as `<Input />`, `<SelectTrigger />`, `<Checkbox />`, etc.

```tsx showLineNumbers title="form.tsx" {3,11,13}
<FormischField of={form} path={["email"]}>
  {(field) => (
    <Field data-invalid={!!field.errors}>
      <FieldLabel for="form-email">Email</FieldLabel>
      <Input
        {...field.props}
        id="form-email"
        value={field.input ?? ""}
        onValueChange={field.onInput}
        type="email"
        aria-invalid={field.errors ? "true" : undefined}
      />
      <FieldError errors={field.errors?.map((message) => ({ message }))} />
    </Field>
  )}
</FormischField>
```

<Callout>
  **Note:** Pass `aria-invalid` as the string `"true"`. Solid 2 renders a
  boolean `true` as an empty attribute, which assistive technologies don't read
  as invalid and the `aria-invalid:` styles don't match. `data-invalid` only
  checks whether the attribute is present, so a boolean works there.
</Callout>

## Working with Different Field Types

Formisch exposes two ways to bind a field to an element:

- **Text inputs** (like `<Input />` and `<Textarea />`): spread `field.props` and provide `value={field.input}`. Formisch wires up `name`, `ref`, `onInput`, `onChange`, `onBlur`, and `onFocus` for you. `<Input />` controls its value, so also pass `onValueChange={field.onInput}`.
- **Component inputs** (like `<Select />`, `<Checkbox />`, `<RadioGroup />` and `<Switch />`): read the value from `field.input` and call `field.onInput(value)` to update it.

Component inputs don't report blur to Formisch on their own. The examples validate on submit, so they don't need it. For the `blur` modes, pass `onBlur={field.props.onBlur}` to a `<Checkbox />` or `<Switch />`. A `<Select />` moves focus into its popup when it opens, and a `<RadioGroup />` moves it between its items, so a blur handler on either would validate before a choice is made. Leave it out there; they then validate on submit.

### Input

- For input fields, spread `field.props`, provide `value={field.input}` and pass `onValueChange={field.onInput}`.
- To show errors, add the `aria-invalid` prop to the `<Input />` component and the `data-invalid` prop to the `<Field />` component.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"

const FormSchema = v.object({
  username: v.pipe(
    v.string(),
    v.minLength(3, "Username must be at least 3 characters."),
    v.maxLength(10, "Username must be at most 10 characters."),
    v.regex(
      /^[a-zA-Z0-9_]+$/,
      "Username can only contain letters, numbers, and underscores."
    )
  )
})

export default function FormFormischInput() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      username: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Profile Settings</CardTitle>
        <CardDescription>
          Update your profile information below.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-input" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["username"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-input-username">
                    Username
                  </FieldLabel>
                  <Input
                    {...field.props}
                    id="form-formisch-input-username"
                    value={field.input ?? ""}
                    onValueChange={field.onInput}
                    aria-invalid={field.errors ? "true" : undefined}
                    placeholder="solidui"
                    autocomplete="username"
                  />
                  <FieldDescription>
                    This is your public display name. Must be between 3 and 10
                    characters. Must only contain letters, numbers, and
                    underscores.
                  </FieldDescription>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-input">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {5-10}
<FormischField of={form} path={["username"]}>
  {(field) => (
    <Field data-invalid={!!field.errors}>
      <FieldLabel for="form-username">Username</FieldLabel>
      <Input
        {...field.props}
        id="form-username"
        value={field.input ?? ""}
        onValueChange={field.onInput}
        aria-invalid={field.errors ? "true" : undefined}
      />
      <FieldError errors={field.errors?.map((message) => ({ message }))} />
    </Field>
  )}
</FormischField>
```

### Textarea

- For textarea fields, spread `field.props` and provide `value={field.input}`.
- To show errors, add the `aria-invalid` prop to the `<Textarea />` component and the `data-invalid` prop to the `<Field />` component.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import { Textarea } from "~/components/ui/textarea"

const FormSchema = v.object({
  about: v.pipe(
    v.string(),
    v.minLength(10, "Please provide at least 10 characters."),
    v.maxLength(200, "Please keep it under 200 characters.")
  )
})

export default function FormFormischTextarea() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      about: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Personalization</CardTitle>
        <CardDescription>
          Customize your experience by telling us more about yourself.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-textarea" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["about"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-textarea-about">
                    More about you
                  </FieldLabel>
                  <Textarea
                    {...field.props}
                    id="form-formisch-textarea-about"
                    value={field.input ?? ""}
                    aria-invalid={field.errors ? "true" : undefined}
                    placeholder="I'm a software engineer..."
                    class="min-h-[120px]"
                  />
                  <FieldDescription>
                    Tell us more about yourself. This will be used to help us
                    personalize your experience.
                  </FieldDescription>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-textarea">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {5-11}
<FormischField of={form} path={["about"]}>
  {(field) => (
    <Field data-invalid={!!field.errors}>
      <FieldLabel for="form-about">More about you</FieldLabel>
      <Textarea
        {...field.props}
        id="form-about"
        value={field.input ?? ""}
        aria-invalid={field.errors ? "true" : undefined}
        placeholder="I'm a software engineer..."
        class="min-h-[120px]"
      />
      <FieldDescription>
        Tell us more about yourself. This will be used to help us personalize
        your experience.
      </FieldDescription>
      <FieldError errors={field.errors?.map((message) => ({ message }))} />
    </Field>
  )}
</FormischField>
```

### Select

- For select components, read `field.input` and call `field.onInput` from `<Select />`'s `onValueChange`.
- To show errors, add the `aria-invalid` prop to the `<SelectTrigger />` component and the `data-invalid` prop to the `<Field />` component.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { For } from "solid-js"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectSeparator,
  SelectTrigger,
  SelectValue
} from "~/components/ui/select"

const spokenLanguages = [
  { label: "English", value: "en" },
  { label: "Spanish", value: "es" },
  { label: "French", value: "fr" },
  { label: "German", value: "de" },
  { label: "Italian", value: "it" },
  { label: "Chinese", value: "zh" },
  { label: "Japanese", value: "ja" }
] as const

const FormSchema = v.object({
  language: v.pipe(
    v.string(),
    v.minLength(1, "Please select your spoken language."),
    v.check(
      (value) => value !== "auto",
      "Auto-detection is not allowed. Please select a specific language."
    )
  )
})

export default function FormFormischSelect() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      language: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-lg">
      <CardHeader>
        <CardTitle>Language Preferences</CardTitle>
        <CardDescription>
          Select your preferred spoken language.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-select" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["language"]}>
              {(field) => (
                <Field orientation="responsive" data-invalid={!!field.errors}>
                  <FieldContent>
                    <FieldLabel for="form-formisch-select-language">
                      Spoken Language
                    </FieldLabel>
                    <FieldDescription>
                      For best results, select the language you speak.
                    </FieldDescription>
                    <FieldError
                      errors={field.errors?.map((message) => ({ message }))}
                    />
                  </FieldContent>
                  <Select
                    value={field.input || null}
                    onValueChange={(value) => field.onInput(value ?? "")}
                    placeholder="Select"
                  >
                    <SelectTrigger
                      id="form-formisch-select-language"
                      aria-invalid={field.errors ? "true" : undefined}
                      class="min-w-[120px]"
                    >
                      <SelectValue />
                    </SelectTrigger>
                    <SelectContent alignItemWithTrigger>
                      <SelectItem value="auto">Auto</SelectItem>
                      <SelectSeparator />
                      <For each={spokenLanguages}>
                        {(language) => (
                          <SelectItem value={language.value}>
                            {language.label}
                          </SelectItem>
                        )}
                      </For>
                    </SelectContent>
                  </Select>
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-select">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {10-14}
<FormischField of={form} path={["language"]}>
  {(field) => (
    <Field orientation="responsive" data-invalid={!!field.errors}>
      <FieldContent>
        <FieldLabel for="form-language">Spoken Language</FieldLabel>
        <FieldDescription>
          For best results, select the language you speak.
        </FieldDescription>
        <FieldError errors={field.errors?.map((message) => ({ message }))} />
      </FieldContent>
      <Select
        value={field.input || null}
        onValueChange={(value) => field.onInput(value ?? "")}
        placeholder="Select"
      >
        <SelectTrigger
          id="form-language"
          aria-invalid={field.errors ? "true" : undefined}
          class="min-w-[120px]"
        >
          <SelectValue />
        </SelectTrigger>
        <SelectContent alignItemWithTrigger>
          <SelectItem value="auto">Auto</SelectItem>
          <SelectItem value="en">English</SelectItem>
        </SelectContent>
      </Select>
    </Field>
  )}
</FormischField>
```

### Checkbox

- For checkbox arrays, read `field.input` and update it from `onCheckedChange` using `field.onInput`.
- To show errors, add the `aria-invalid` prop to the `<Checkbox />` component and the `data-invalid` prop to the `<Field />` component.
- Remember to add `data-slot="checkbox-group"` to the `<FieldGroup />` component for proper styling and spacing.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { For } from "solid-js"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import { Checkbox } from "~/components/ui/checkbox"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSeparator,
  FieldSet
} from "~/components/ui/field"

const tasks = [
  {
    id: "push",
    label: "Push notifications"
  },
  {
    id: "email",
    label: "Email notifications"
  }
] as const

const FormSchema = v.object({
  responses: v.boolean(),
  tasks: v.pipe(
    v.array(v.string()),
    v.minLength(1, "Please select at least one notification type."),
    v.check(
      (value) => value.every((task) => tasks.some((t) => t.id === task)),
      "Invalid notification type selected."
    )
  )
})

export default function FormFormischCheckbox() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      responses: true,
      tasks: []
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Notifications</CardTitle>
        <CardDescription>Manage your notification preferences.</CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-checkbox" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["responses"]}>
              {(field) => (
                <div>
                  <FieldSet data-invalid={!!field.errors}>
                    <FieldLegend variant="label">Responses</FieldLegend>
                    <FieldDescription>
                      Get notified for requests that take time, like research or
                      image generation.
                    </FieldDescription>
                    <FieldGroup data-slot="checkbox-group">
                      <Field orientation="horizontal">
                        <Checkbox
                          id="form-formisch-checkbox-responses"
                          checked={field.input ?? false}
                          onCheckedChange={(checked) =>
                            field.onInput(checked === true)
                          }
                          disabled
                        />
                        <FieldLabel
                          for="form-formisch-checkbox-responses"
                          class="font-normal"
                        >
                          Push notifications
                        </FieldLabel>
                      </Field>
                    </FieldGroup>
                  </FieldSet>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </div>
              )}
            </FormischField>
            <FieldSeparator />
            <FormischField of={form} path={["tasks"]}>
              {(field) => (
                <FieldGroup>
                  <FieldSet data-invalid={!!field.errors}>
                    <FieldLegend variant="label">Tasks</FieldLegend>
                    <FieldDescription>
                      Get notified when tasks you've created have updates.
                    </FieldDescription>
                    <FieldGroup data-slot="checkbox-group">
                      <For each={tasks}>
                        {(task) => (
                          <Field
                            orientation="horizontal"
                            data-invalid={!!field.errors}
                          >
                            <Checkbox
                              id={`form-formisch-checkbox-${task.id}`}
                              aria-invalid={field.errors ? "true" : undefined}
                              checked={(field.input ?? []).includes(task.id)}
                              onCheckedChange={(checked) => {
                                const current = field.input ?? []
                                field.onInput(
                                  checked === true
                                    ? [...current, task.id]
                                    : current.filter(
                                        (value) => value !== task.id
                                      )
                                )
                              }}
                            />
                            <FieldLabel
                              for={`form-formisch-checkbox-${task.id}`}
                              class="font-normal"
                            >
                              {task.label}
                            </FieldLabel>
                          </Field>
                        )}
                      </For>
                    </FieldGroup>
                  </FieldSet>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </FieldGroup>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-checkbox">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {7,11-24}
<FormischField of={form} path={["tasks"]}>
  {(field) => (
    <FieldSet>
      <FieldLegend variant="label">Tasks</FieldLegend>
      <FieldDescription>
        Get notified when tasks you've created have updates.
      </FieldDescription>
      <FieldGroup data-slot="checkbox-group">
        <For each={tasks}>
          {(task) => (
            <Field orientation="horizontal" data-invalid={!!field.errors}>
              <Checkbox
                id={`form-checkbox-${task.id}`}
                aria-invalid={field.errors ? "true" : undefined}
                checked={(field.input ?? []).includes(task.id)}
                onCheckedChange={(checked) => {
                  const current = field.input ?? []
                  field.onInput(
                    checked === true
                      ? [...current, task.id]
                      : current.filter((value) => value !== task.id)
                  )
                }}
              />
              <FieldLabel for={`form-checkbox-${task.id}`} class="font-normal">
                {task.label}
              </FieldLabel>
            </Field>
          )}
        </For>
      </FieldGroup>
      <FieldError errors={field.errors?.map((message) => ({ message }))} />
    </FieldSet>
  )}
</FormischField>
```

### Radio Group

- For radio groups, read `field.input` and call `field.onInput` from `onValueChange`.
- To show errors, add the `aria-invalid` prop to the `<RadioGroupItem />` component and the `data-invalid` prop to the `<Field />` component.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { For } from "solid-js"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSet,
  FieldTitle
} from "~/components/ui/field"
import { RadioGroup, RadioGroupItem } from "~/components/ui/radio-group"

const plans = [
  {
    id: "starter",
    title: "Starter (100K tokens/month)",
    description: "For everyday use with basic features."
  },
  {
    id: "pro",
    title: "Pro (1M tokens/month)",
    description: "For advanced AI usage with more features."
  },
  {
    id: "enterprise",
    title: "Enterprise (Unlimited tokens)",
    description: "For large teams and heavy usage."
  }
] as const

const FormSchema = v.object({
  plan: v.pipe(
    v.string(),
    v.minLength(1, "You must select a subscription plan to continue.")
  )
})

export default function FormFormischRadioGroup() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      plan: ""
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Subscription Plan</CardTitle>
        <CardDescription>
          See pricing and features for each plan.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-radiogroup" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["plan"]}>
              {(field) => (
                <FieldSet data-invalid={!!field.errors}>
                  <FieldLegend>Plan</FieldLegend>
                  <FieldDescription>
                    You can upgrade or downgrade your plan at any time.
                  </FieldDescription>
                  <RadioGroup
                    aria-label="Plan"
                    value={field.input || null}
                    onValueChange={(value) => field.onInput(String(value))}
                    aria-invalid={field.errors ? "true" : undefined}
                  >
                    <For each={plans}>
                      {(plan) => (
                        <FieldLabel for={`form-formisch-radiogroup-${plan.id}`}>
                          <Field
                            orientation="horizontal"
                            data-invalid={!!field.errors}
                          >
                            <FieldContent>
                              <FieldTitle>{plan.title}</FieldTitle>
                              <FieldDescription>
                                {plan.description}
                              </FieldDescription>
                            </FieldContent>
                            <RadioGroupItem
                              value={plan.id}
                              id={`form-formisch-radiogroup-${plan.id}`}
                              aria-invalid={field.errors ? "true" : undefined}
                            />
                          </Field>
                        </FieldLabel>
                      )}
                    </For>
                  </RadioGroup>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </FieldSet>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-radiogroup">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {8-12,24}
<FormischField of={form} path={["plan"]}>
  {(field) => (
    <FieldSet>
      <FieldLegend>Plan</FieldLegend>
      <FieldDescription>
        You can upgrade or downgrade your plan at any time.
      </FieldDescription>
      <RadioGroup
        aria-label="Plan"
        value={field.input || null}
        onValueChange={(value) => field.onInput(String(value))}
      >
        <For each={plans}>
          {(plan) => (
            <FieldLabel for={`form-radiogroup-${plan.id}`}>
              <Field orientation="horizontal" data-invalid={!!field.errors}>
                <FieldContent>
                  <FieldTitle>{plan.title}</FieldTitle>
                  <FieldDescription>{plan.description}</FieldDescription>
                </FieldContent>
                <RadioGroupItem
                  value={plan.id}
                  id={`form-radiogroup-${plan.id}`}
                  aria-invalid={field.errors ? "true" : undefined}
                />
              </Field>
            </FieldLabel>
          )}
        </For>
      </RadioGroup>
      <FieldError errors={field.errors?.map((message) => ({ message }))} />
    </FieldSet>
  )}
</FormischField>
```

### Switch

- For switches, read `field.input` and call `field.onInput` from `onCheckedChange`.
- To show errors, add the `aria-invalid` prop to the `<Switch />` component and the `data-invalid` prop to the `<Field />` component.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel
} from "~/components/ui/field"
import { Switch } from "~/components/ui/switch"

const FormSchema = v.object({
  twoFactor: v.pipe(
    v.boolean(),
    v.check(
      (value) => value === true,
      "It is highly recommended to enable two-factor authentication."
    )
  )
})

export default function FormFormischSwitch() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      twoFactor: false
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Security Settings</CardTitle>
        <CardDescription>
          Manage your account security preferences.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-switch" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["twoFactor"]}>
              {(field) => (
                <Field orientation="horizontal" data-invalid={!!field.errors}>
                  <FieldContent>
                    <FieldLabel for="form-formisch-switch-twoFactor">
                      Multi-factor authentication
                    </FieldLabel>
                    <FieldDescription>
                      Enable multi-factor authentication to secure your account.
                    </FieldDescription>
                    <FieldError
                      errors={field.errors?.map((message) => ({ message }))}
                    />
                  </FieldContent>
                  <Switch
                    id="form-formisch-switch-twoFactor"
                    checked={field.input ?? false}
                    onCheckedChange={(checked) => field.onInput(checked)}
                    aria-invalid={field.errors ? "true" : undefined}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter>
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-switch">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

```tsx showLineNumbers title="form.tsx" {13-18}
<FormischField of={form} path={["twoFactor"]}>
  {(field) => (
    <Field orientation="horizontal" data-invalid={!!field.errors}>
      <FieldContent>
        <FieldLabel for="form-twoFactor">
          Multi-factor authentication
        </FieldLabel>
        <FieldDescription>
          Enable multi-factor authentication to secure your account.
        </FieldDescription>
        <FieldError errors={field.errors?.map((message) => ({ message }))} />
      </FieldContent>
      <Switch
        id="form-twoFactor"
        checked={field.input ?? false}
        onCheckedChange={(checked) => field.onInput(checked)}
        aria-invalid={field.errors ? "true" : undefined}
      />
    </Field>
  )}
</FormischField>
```

### Complex Forms

Here is an example of a more complex form with multiple fields and validation.

```tsx
import {
  createForm,
  Field as FormischField,
  Form,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { For } from "solid-js"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import { Checkbox } from "~/components/ui/checkbox"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSeparator,
  FieldSet,
  FieldTitle
} from "~/components/ui/field"
import { RadioGroup, RadioGroupItem } from "~/components/ui/radio-group"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "~/components/ui/select"
import { Switch } from "~/components/ui/switch"

const addons = [
  {
    id: "analytics",
    title: "Analytics",
    description: "Advanced analytics and reporting"
  },
  {
    id: "backup",
    title: "Backup",
    description: "Automated daily backups"
  },
  {
    id: "support",
    title: "Priority Support",
    description: "24/7 premium customer support"
  }
] as const

const FormSchema = v.object({
  plan: v.pipe(
    v.string(),
    v.minLength(1, "Please select a subscription plan"),
    v.check(
      (value) => value === "basic" || value === "pro",
      "Invalid plan selection. Please choose Basic or Pro"
    )
  ),
  billingPeriod: v.pipe(
    v.string(),
    v.minLength(1, "Please select a billing period")
  ),
  addons: v.pipe(
    v.array(v.string()),
    v.minLength(1, "Please select at least one add-on"),
    v.maxLength(3, "You can select up to 3 add-ons"),
    v.check(
      (value) => value.every((addon) => addons.some((a) => a.id === addon)),
      "You selected an invalid add-on"
    )
  ),
  emailNotifications: v.boolean()
})

export default function FormFormischComplex() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      plan: "basic",
      billingPeriod: "",
      addons: [],
      emailNotifications: false
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full max-w-sm">
      <CardHeader class="border-b">
        <CardTitle>You're almost there!</CardTitle>
        <CardDescription>
          Choose your subscription plan and billing period.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-complex" onSubmit={handleSubmit}>
          <FieldGroup>
            <FormischField of={form} path={["plan"]}>
              {(field) => (
                <FieldSet data-invalid={!!field.errors}>
                  <FieldLegend variant="label">Subscription Plan</FieldLegend>
                  <FieldDescription>
                    Choose your subscription plan.
                  </FieldDescription>
                  <RadioGroup
                    aria-label="Subscription Plan"
                    value={field.input || null}
                    onValueChange={(value) => field.onInput(String(value))}
                    aria-invalid={field.errors ? "true" : undefined}
                  >
                    <FieldLabel for="form-formisch-complex-basic">
                      <Field orientation="horizontal">
                        <FieldContent>
                          <FieldTitle>Basic</FieldTitle>
                          <FieldDescription>
                            For individuals and small teams
                          </FieldDescription>
                        </FieldContent>
                        <RadioGroupItem
                          value="basic"
                          id="form-formisch-complex-basic"
                        />
                      </Field>
                    </FieldLabel>
                    <FieldLabel for="form-formisch-complex-pro">
                      <Field orientation="horizontal">
                        <FieldContent>
                          <FieldTitle>Pro</FieldTitle>
                          <FieldDescription>
                            For businesses with higher demands
                          </FieldDescription>
                        </FieldContent>
                        <RadioGroupItem
                          value="pro"
                          id="form-formisch-complex-pro"
                        />
                      </Field>
                    </FieldLabel>
                  </RadioGroup>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </FieldSet>
              )}
            </FormischField>
            <FieldSeparator />
            <FormischField of={form} path={["billingPeriod"]}>
              {(field) => (
                <Field data-invalid={!!field.errors}>
                  <FieldLabel for="form-formisch-complex-billingPeriod">
                    Billing Period
                  </FieldLabel>
                  <Select
                    value={field.input || null}
                    onValueChange={(value) => field.onInput(value ?? "")}
                    placeholder="Select"
                  >
                    <SelectTrigger
                      id="form-formisch-complex-billingPeriod"
                      aria-invalid={field.errors ? "true" : undefined}
                    >
                      <SelectValue />
                    </SelectTrigger>
                    <SelectContent>
                      <SelectItem value="monthly">Monthly</SelectItem>
                      <SelectItem value="yearly">Yearly</SelectItem>
                    </SelectContent>
                  </Select>
                  <FieldDescription>
                    Choose how often you want to be billed.
                  </FieldDescription>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
            <FieldSeparator />
            <FormischField of={form} path={["addons"]}>
              {(field) => (
                <FieldSet>
                  <FieldLegend>Add-ons</FieldLegend>
                  <FieldDescription>
                    Select additional features you'd like to include.
                  </FieldDescription>
                  <FieldGroup data-slot="checkbox-group">
                    <For each={addons}>
                      {(addon) => (
                        <Field
                          orientation="horizontal"
                          data-invalid={!!field.errors}
                        >
                          <Checkbox
                            id={`form-formisch-complex-${addon.id}`}
                            aria-invalid={field.errors ? "true" : undefined}
                            checked={(field.input ?? []).includes(addon.id)}
                            onCheckedChange={(checked) => {
                              const current = field.input ?? []
                              field.onInput(
                                checked === true
                                  ? [...current, addon.id]
                                  : current.filter(
                                      (value) => value !== addon.id
                                    )
                              )
                            }}
                          />
                          <FieldContent>
                            <FieldLabel
                              for={`form-formisch-complex-${addon.id}`}
                            >
                              {addon.title}
                            </FieldLabel>
                            <FieldDescription>
                              {addon.description}
                            </FieldDescription>
                          </FieldContent>
                        </Field>
                      )}
                    </For>
                  </FieldGroup>
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </FieldSet>
              )}
            </FormischField>
            <FieldSeparator />
            <FormischField of={form} path={["emailNotifications"]}>
              {(field) => (
                <Field orientation="horizontal" data-invalid={!!field.errors}>
                  <FieldContent>
                    <FieldLabel for="form-formisch-complex-emailNotifications">
                      Email Notifications
                    </FieldLabel>
                    <FieldDescription>
                      Receive email updates about your subscription
                    </FieldDescription>
                  </FieldContent>
                  <Switch
                    id="form-formisch-complex-emailNotifications"
                    checked={field.input ?? false}
                    onCheckedChange={(checked) => field.onInput(checked)}
                    aria-invalid={field.errors ? "true" : undefined}
                  />
                  <FieldError
                    errors={field.errors?.map((message) => ({ message }))}
                  />
                </Field>
              )}
            </FormischField>
          </FieldGroup>
        </Form>
      </CardContent>
      <CardFooter class="border-t">
        <Field>
          <Button type="submit" form="form-formisch-complex">
            Save Preferences
          </Button>
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

## Resetting the Form

Formisch exposes a top-level `reset` function. Pass the form store to reset it to its initial input.

```tsx showLineNumbers
<Button type="button" variant="outline" onClick={() => reset(form)}>
  Reset
</Button>
```

You can also reset to new initial values, or reset while keeping the user's current input:

```tsx showLineNumbers
// Reset to a fresh set of initial values
reset(form, { initialInput: { title: "", description: "" } })

// Sync the baseline to new server data, but keep the user's edits
reset(form, { initialInput: serverData, keepInput: true })
```

## Array Fields

Formisch provides a `<FieldArray />` component and a set of helper functions for managing dynamic array fields. Use it whenever you need to add, remove, or reorder items.

```tsx
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
  createForm,
  FieldArray,
  Field as FormischField,
  Form,
  insert,
  remove,
  reset,
  type SubmitHandler
} from "@formisch/solid/v2"
import { For, Show } from "solid-js"
import { toast } from "solid-sonner"
import * as v from "valibot"

import { Button } from "~/components/ui/button"
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle
} from "~/components/ui/card"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLegend,
  FieldSet
} from "~/components/ui/field"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput
} from "~/components/ui/input-group"

const FormSchema = v.object({
  emails: v.pipe(
    v.array(
      v.object({
        address: v.pipe(
          v.string(),
          v.nonEmpty("Enter an email address."),
          v.email("Enter a valid email address.")
        )
      })
    ),
    v.minLength(1, "Add at least one email address."),
    v.maxLength(5, "You can add up to 5 email addresses.")
  )
})

export default function FormFormischArray() {
  const form = createForm({
    schema: FormSchema,
    initialInput: {
      emails: [{ address: "" }, { address: "" }]
    }
  })

  const handleSubmit: SubmitHandler<typeof FormSchema> = (output) => {
    toast("You submitted the following values:", {
      description: () => (
        <pre class="mt-2 w-[320px] overflow-x-auto rounded-md bg-muted p-4 text-foreground">
          <code>{JSON.stringify(output, null, 2)}</code>
        </pre>
      ),
      position: "bottom-right",
      classNames: {
        content: "flex flex-col gap-2"
      },
      style: {
        "--border-radius": "calc(var(--radius) + 4px)"
      }
    })
  }

  return (
    <Card class="w-full sm:max-w-md">
      <CardHeader class="border-b">
        <CardTitle>Contact Emails</CardTitle>
        <CardDescription>Manage your contact email addresses.</CardDescription>
      </CardHeader>
      <CardContent>
        <Form of={form} id="form-formisch-array" onSubmit={handleSubmit}>
          <FieldArray of={form} path={["emails"]}>
            {(fieldArray) => (
              <FieldSet class="gap-4">
                <FieldLegend variant="label">Email Addresses</FieldLegend>
                <FieldDescription>
                  Add up to 5 email addresses where we can contact you.
                </FieldDescription>
                <FieldGroup class="gap-4">
                  <For each={fieldArray.items}>
                    {(_item, index) => (
                      <FormischField
                        of={form}
                        path={["emails", index(), "address"]}
                      >
                        {(field) => (
                          <Field
                            orientation="horizontal"
                            data-invalid={!!field.errors}
                          >
                            <FieldContent>
                              <InputGroup>
                                <InputGroupInput
                                  {...field.props}
                                  id={`form-formisch-array-email-${index()}`}
                                  aria-label={`Email address ${index() + 1}`}
                                  value={field.input ?? ""}
                                  onValueChange={field.onInput}
                                  aria-invalid={
                                    field.errors ? "true" : undefined
                                  }
                                  placeholder="name@example.com"
                                  type="email"
                                  autocomplete="email"
                                />
                                <Show when={fieldArray.items.length > 1}>
                                  <InputGroupAddon align="inline-end">
                                    <InputGroupButton
                                      type="button"
                                      variant="ghost"
                                      size="icon-xs"
                                      onClick={() =>
                                        remove(form, {
                                          path: ["emails"],
                                          at: index()
                                        })
                                      }
                                      aria-label={`Remove email ${index() + 1}`}
                                    >
                                      <svg
                                        width="24"
                                        height="24"
                                        viewBox="0 0 24 24"
                                        fill="none"
                                        stroke="currentColor"
                                        stroke-width="2"
                                        stroke-linecap="round"
                                        stroke-linejoin="round"
                                        aria-hidden="true"
                                      >
                                        <path d="M18 6 6 18" />
                                        <path d="m6 6 12 12" />
                                      </svg>
                                    </InputGroupButton>
                                  </InputGroupAddon>
                                </Show>
                              </InputGroup>
                              <FieldError
                                errors={field.errors?.map((message) => ({
                                  message
                                }))}
                              />
                            </FieldContent>
                          </Field>
                        )}
                      </FormischField>
                    )}
                  </For>
                  <Button
                    type="button"
                    variant="outline"
                    size="sm"
                    onClick={() =>
                      insert(form, {
                        path: ["emails"],
                        initialInput: { address: "" }
                      })
                    }
                    disabled={fieldArray.items.length >= 5}
                  >
                    Add Email Address
                  </Button>
                </FieldGroup>
                <FieldError
                  errors={fieldArray.errors?.map((message) => ({ message }))}
                />
              </FieldSet>
            )}
          </FieldArray>
        </Form>
      </CardContent>
      <CardFooter class="border-t">
        <Field orientation="horizontal">
          <Button type="button" variant="outline" onClick={() => reset(form)}>
            Reset
          </Button>
          <Button type="submit" form="form-formisch-array">
            Save
          </Button>
        </Field>
      </CardFooter>
    </Card>
  )
}
```

### Using FieldArray

`<FieldArray />` follows the same render-prop pattern as `<Field />`. Its `items` array holds a stable ID per item, so `<For>` keeps each row's DOM when items move or are removed.

```tsx showLineNumbers title="form.tsx" {1-6,11-26}
import {
  FieldArray,
  Field as FormischField,
  insert,
  remove
} from "@formisch/solid/v2"

export function ExampleForm() {
  // ... form config

  return (
    <FieldArray of={form} path={["emails"]}>
      {(fieldArray) => (
        <FieldGroup class="gap-4">
          <For each={fieldArray.items}>
            {(_item, index) => (
              <FormischField of={form} path={["emails", index(), "address"]}>
                {(field) => /* ... */}
              </FormischField>
            )}
          </For>
        </FieldGroup>
      )}
    </FieldArray>
  )
}
```

### Array Field Structure

Wrap your array fields in a `<FieldSet />` with a `<FieldLegend />` and `<FieldDescription />`.

```tsx showLineNumbers title="form.tsx"
<FieldSet class="gap-4">
  <FieldLegend variant="label">Email Addresses</FieldLegend>
  <FieldDescription>
    Add up to 5 email addresses where we can contact you.
  </FieldDescription>
  <FieldGroup class="gap-4">{/* Array items go here */}</FieldGroup>
</FieldSet>
```

### Adding Items

Use the `insert` function to add new items to the array. By default new items are appended to the end. You can also pass an `at` index to insert at a specific position.

```tsx showLineNumbers title="form.tsx"
<Button
  type="button"
  variant="outline"
  size="sm"
  onClick={() =>
    insert(form, { path: ["emails"], initialInput: { address: "" } })
  }
  disabled={fieldArray.items.length >= 5}
>
  Add Email Address
</Button>
```

### Removing Items

Use the `remove` function with an `at` index to remove items from the array.

```tsx showLineNumbers title="form.tsx"
<Show when={fieldArray.items.length > 1}>
  <InputGroupAddon align="inline-end">
    <InputGroupButton
      type="button"
      variant="ghost"
      size="icon-xs"
      onClick={() => remove(form, { path: ["emails"], at: index() })}
      aria-label={`Remove email ${index() + 1}`}
    >
      <XIcon />
    </InputGroupButton>
  </InputGroupAddon>
</Show>
```

Formisch also exposes `move`, `swap`, and `replace` for reordering and replacing items. They follow the same `(form, config)` signature.

### Array Validation

Use Valibot's `array` and pipeline validators to constrain array fields.

```tsx showLineNumbers title="form.tsx"
const FormSchema = v.object({
  emails: v.pipe(
    v.array(
      v.object({
        address: v.pipe(
          v.string(),
          v.nonEmpty("Enter an email address."),
          v.email("Enter a valid email address.")
        )
      })
    ),
    v.minLength(1, "Add at least one email address."),
    v.maxLength(5, "You can add up to 5 email addresses.")
  )
})
```

## Notes for Solid

- `<Form />` always sets `novalidate`, and Formisch names each control after its path (for example `name='["title"]'`). Handle submissions in `onSubmit` rather than reading a native `FormData`.
- Create the form store inside the component that renders the form, as in the examples. In Astro, keep the whole form inside one Solid island.
