setValues

Sets multiple values of the form or a field array at once.

// Set multiple form values
setValues(form, values, options);

// Set values of a field array
setValues(form, name, values, options);

Parameters

  • form FormStore
  • name string
  • values FieldValues | (FieldValues | FieldValue)[]
  • options object = {}
    • shouldTouched boolean = true
    • shouldDirty boolean = true
    • shouldValidate boolean = true
    • shouldFocus boolean = true

Explanation

By default, the fields are set to touched and the dirty state is updated. If you don't want this, you can set shouldTouched and/or shouldDirty to false.

By default, the fields are validated according to the rules defined in the options of the createForm primitive. To disable validation you can set shouldValidate to false.

By default, a field is focused when an error occurs during validation. To change this behavior you can set shouldFocus to false.