# Form methods

> This document is the Markdown version of [formisch.dev/vue/guides/form-methods/](https://formisch.dev/vue/guides/form-methods/). For the complete documentation index, see [llms.txt](https://formisch.dev/llms.txt).

To retrieve the values of your form or to make changes to the form, Formisch provides you with several methods. These apply either to the entire form or to individual fields.

## Reading values

To retrieve values from your form, you can use:

- [`getInput`](/methods/api/getInput.md): Get the current value
  of a specific field
- [`getErrors`](/methods/api/getErrors.md): Get error messages
  for a specific field
- [`getDeepError`](/methods/api/getDeepError.md): Get the first
  error message within a field or the form
- [`getDeepErrors`](/methods/api/getDeepErrors.md): Get all error
  messages across the entire form
- [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md): Get
  the error messages of the first erroring field paired with its path
- [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md):
  Get all error messages paired with the path of the field they belong to

Formisch uses Vue's reactivity system internally, which means that reading values with these methods is reactive. When the form state changes, any component or computation that uses these methods will automatically update to reflect the new state.

## Field state

To check the state of a single field or of the entire form, use:

- [`isTouched`](/methods/api/isTouched.md): Whether the field or
  form has been touched
- [`isEdited`](/methods/api/isEdited.md): Whether the field or
  form has been edited
- [`isDirty`](/methods/api/isDirty.md): Whether the field or form
  differs from its initial input
- [`isValid`](/methods/api/isValid.md): Whether the field or form
  has no validation errors

Each of these takes an optional `path` to scope the check to a single field. Without it, they walk the entire form.

## Dirty state

To work with the dirty state of your form, Formisch provides three methods:

- [`getDirtyInput`](/methods/api/getDirtyInput.md): Get the dirty
  parts of the form input
- [`getDirtyPaths`](/methods/api/getDirtyPaths.md): Get the paths
  of dirty fields
- [`pickDirty`](/methods/api/pickDirty.md): Filter an
  externally-supplied value down to its dirty parts using the form's dirty mask

See the [dirty fields](/vue/guides/dirty-fields.md) guide for when to reach for each.

## Setting values

To manually update form values or errors, use:

- [`setInput`](/methods/api/setInput.md): Manually update the
  value of a specific field
- [`setErrors`](/methods/api/setErrors.md): Manually set error
  messages for a specific field

> If you need to update the form because the initial data has changed (e.g., remote data was refreshed), use [`reset`](/methods/api/reset.md) with a new `initialInput` instead of `setInput`. The `reset` method properly reinitializes the form state, while `setInput` only changes the current input values without updating the initial state.

## Form control

To control the form programmatically, use:

- [`handleSubmit`](/methods/api/handleSubmit.md): Create a submit
  event handler that validates the form and calls your handler on success
- [`reset`](/methods/api/reset.md): Reset the form to its initial
  state or update initial values
- [`validate`](/methods/api/validate.md): Manually trigger
  validation of the entire form
- [`submit`](/methods/api/submit.md): Programmatically trigger
  form submission
- [`focus`](/methods/api/focus.md): Focus on a specific field

## Array operations

For working with field arrays, Formisch provides:

- [`insert`](/methods/api/insert.md): Insert a new item into a
  field array
- [`remove`](/methods/api/remove.md): Remove an item from a field
  array
- [`move`](/methods/api/move.md): Move an item to a different
  position in a field array
- [`swap`](/methods/api/swap.md): Swap two items in a field array
- [`replace`](/methods/api/replace.md): Replace an item in a
  field array

## API design

All methods in Formisch follow a consistent API pattern: the first parameter is always the form store, and the second parameter (if necessary) is always a config object. This design makes the API flexible and consistent across all methods. Once you understand this pattern, you basically understand the entire API design.

Here are some examples:

```ts
// Get the value of a field
const emailInput = getInput(loginForm, { path: ['email'] });

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

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

## API reference

You can find detailed documentation for each method in our [API reference](/vue/api/).
