Every method of useForm takes a path. Use dots for objects and numbers for list items: user.email, tags.0.label.
Errors use the same flat path, so the error of tags.0.label is form.errors['tags.0.label'].
const form = useForm({
initialValues: { user: { name: '', email: '' } }
})
<Input {...form.getInputProps('user.name')} />
A rule object under a list key runs for every item. Add, remove and reorder items with the list methods. The errors of a list go away when you change it, because their positions change.
Add and remove items. Submit with an empty item to see its error.
| Name | Description | Type |
|---|---|---|
| insertListItem | add an item, at the end when there is no index | (path: string, item: unknown, index?: number) => void |
| removeListItem | remove the item at the index | (path: string, index: number) => void |
| reorderListItem | move an item from one index to another | (path: string, indexes: { from: number; to: number }) => void |
| replaceListItem | replace the item at the index | (path: string, index: number, item: unknown) => void |