Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Accessibility
Vuetify

Sign in

Sign in with your preferred provider to access your account.

createForm

A composable for building reactive forms with validation, field registration, and submission handling. Built on top of the registry system for managing form fields.


Advanced100% coverageFeb 4, 2026

Usage

The form composables provide a powerful interface for managing form state, validation, and submission. Built on the registry pattern, they handle form-specific requirements like validation rules, error states, and field lifecycle management.

Creating a Form

Use createForm to create a new form instance:

ts
import { createForm } from '@vuetify/v0'

const form = createForm()

const email = form.register({
  id: 'email',
  value: '',
  rules: [
    (value) => value.includes('@') || 'Must be a valid email',
    (value) => value.length > 0 || 'Required'
  ]
})

console.log(email.value) // ''
console.log(email.errors.value) // []

Injecting a Form Context

Use useForm to inject an existing form context (typically provided by a parent component):

ts
import { useForm } from '@vuetify/v0'

// Injects the form context provided by an ancestor
const form = useForm()

Reactivity

createForm adds reactive validation state on top of createRegistry. Form-level and field-level state are fully reactive.

Property/MethodReactiveNotes
isValidComputed from all fields
isValidatingComputed from all fields
ticket.valueShallowRef, triggers validation on change
ticket.errorsShallowRef array
ticket.isValidShallowRef (null/true/false)
ticket.isPristineShallowRef boolean
ticket.isValidatingShallowRef boolean
get(id)Returns ticket with reactive refs
values()Use useProxyRegistry() for reactive collection

Architecture

createForm extends createRegistry with validation capabilities:

Form Validation Flow

Use controls to zoom and pan. Click outside or press Escape to close.

Form Validation Flow

API Reference

The following API details are for the createForm composable.

Functions

createForm

(options?: FormOptions) => R

Creates a new form instance.

createFormContext

(_options?: FormContextOptions) => ContextTrinity<R>

Creates a new form context.

useForm

(namespace?: string) => R

Returns the current form instance.

Options

events

boolean

Enable event emission for registry operations

Default: false

reactive

boolean

Enable reactive behavior for registry operations

Default: false

Properties

collection

ReadonlyMap<ID, Z>

The collection of tickets in the registry

size

number

The number of tickets in the registry

isValid

ComputedRef<boolean>

isValidating

ComputedRef<boolean>

Methods

clear

() => void

Clear the entire registry

has

(id: ID) => boolean

Check if a ticket exists by ID

keys

() => readonly ID[]

Get all registered IDs

browse

(value: Z["value"]) => ID[] | undefined

Browse for an ID(s) by value

lookup

(index: number) => ID | undefined

lookup a ticket by index number

get

(id: ID) => Z | undefined

Get a ticket by ID

upsert

(id: ID, ticket?: Partial<Z>) => Z

Update or insert a ticket by ID

values

() => readonly Z[]

Get all values of registered tickets

entries

() => readonly [ID, Z][]

Get all entries of registered tickets

unregister

(id: ID) => void

Unregister a ticket by ID

reindex

() => void

Reset the index directory and update all tickets

seek

(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => Z | undefined

Seek for a ticket based on direction and optional predicate

on

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<Z, K>) => void

Listen for registry events

off

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<Z, K>) => void

Stop listening for registry events

emit

<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<Z, K>) => void

Emit an event with data

dispose

() => void

Clears the registry and removes all listeners

offboard

(ids: ID[]) => void

Offboard multiple tickets at once

batch

<R>(fn: () => R) => R

Execute operations in a batch, deferring cache invalidation and event emission until complete

register

(registration: Partial<Z>) => E

onboard

(registrations: Partial<Z>[]) => E[]

submit

(id?: ID | ID[]) => Promise<boolean>

reset

() => void
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/