reset

Resets the entire form, several fields and field arrays or a single field or field array.

// Reset the entire form
reset(form, options);

// Reset a single field or field array
reset(form, name, options);

// Reset several fields and field arrays
reset(form, names, options);

Parameters

  • form FormStore
  • name string
  • names string[]
  • options object = {}
    • initialValues Maybe<PartialValues<FieldValues>>
    • initialValue Maybe<FieldValue>
    • keepResponse boolean = false
    • keepSubmitCount boolean = false
    • keepSubmitted boolean = false
    • keepValues boolean = false
    • keepDirtyValues boolean = false
    • keepItems boolean = false
    • keepDirtyItems boolean = false
    • keepErrors boolean = false
    • keepTouched boolean = false
    • keepDirty boolean = false

Explanation

In addition to the names of the fields, you can also specify the name of a field array under names or name. In this case, the field array and the fields and field arrays it contains will be reset.

When you reset the entire form or several fields, you can specify new initialValues that override the initialValues you may specified in the createForm primitive.

When you reset a single field, you can specify a new initialValue that override the initial value you may set in the initialValues of the createForm primitive.

By default, the response, submitCount and submitted state of the form is reset when the entire form is reset. To change this behavior you can set keepResponse, keepSubmitCount and/or keepSubmitted to true.

By default, the value, items, error, touched and dirty state of each field and field array are reset. To change this behavior you can set keepValues, keepDirtyValues, keepItems, keepDirtyItems, keepErrors, keepTouched and/or keepDirty to true.