reset

Resets the form or a specific field to its initial state or to a new initial input. Optionally keeps certain states like input values, touched state, or errors.

reset(form);
reset<TSchema, TFieldPath>(form, config);

Generics

Parameters

Explanation

When called without a config or with path set to undefined, the entire form is reset. When a path is provided, only that specific field and its nested fields are reset.

By default, the form resets to its original initial input. However, you can pass a new initialInput in the config to update the form's baseline data. This is useful when remote data has changed and the form needs to reflect the updated values. Combined with keepInput, keepTouched, keepErrors, and keepSubmitted, you can update the initial state without overwriting the user's current edits.

More context on dirty tracking

Formisch distinguishes between two concepts:

  • Initial input: the baseline value used for dirty tracking (often the server state).
  • Current input: the value the user is currently editing (the client state).

Calling reset updates the initial input (baseline). Depending on the keep* options, it can also overwrite the current input, or keep it and just recompute state like isDirty based on the new baseline.

If the initial input is null or undefined, Formisch does not treat an empty string or NaN as dirty. This helps when HTML inputs produce '' or NaN for "empty" values.

Primitives

Methods

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of @fabian-hiller

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of @vasilii-kovalev
  • GitHub profile picture of @saturnonearth
  • GitHub profile picture of @ruiaraujo012
  • GitHub profile picture of @hyunbinseo
  • GitHub profile picture of @nickytonline
  • GitHub profile picture of @KubaJastrz
  • GitHub profile picture of @kibertoad
  • GitHub profile picture of @Thanaen
  • GitHub profile picture of @caegdeveloper
  • GitHub profile picture of @bmoyroud
  • GitHub profile picture of @dslatkin