Forms guide · 5 of 8
Lists and steps
A list is a field with rows you can add, remove and move. Steps are groups in one schema. Neither registers anything: the values live in the form.
Rows you add and remove field
field('members') gives the list’s items and its operations: push, insert, remove, move, swap, replace and clear. item.key stays the same through edits and moves, so use it as the v-for key. A list’s own error, such as “add at least one”, is errors.members.
Steps validate()
Each step is a group in the schema. validate('account') checks one group and shows only its errors. A step that isn’t on screen keeps what was typed, and the final submit checks every step.
Unions
A discriminated union has the fields of every branch, and the schema validates the active one. Switch to bank transfer and back: the card number you typed is still there. onSubmit gets the active branch only.
A schema that changes
schema can be a ref, for forms built from data. A new schema validates the same values again.
const schema = ref(schemas.personal)
const form = useForm({ schema })
// A new schema validates the same values again.
form.model.kind.watch(({ value }) => (schema.value = schemas[value]))