setValue
Sets the value of the specified field.
setValue(form, name, value, options);
Parameters
form
FormStore
name
string
value
FieldValue
options
object =
{}
shouldTouched
boolean =
true
shouldDirty
boolean =
true
shouldValidate
boolean =
true
shouldFocus
boolean =
true
Explanation
By default, the field is 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 field is validated according to the rules defined in the options
of the useForm
hook. To disable validation you can set shouldValidate
to false
.
By default, the field is focused when an error occurs during validation. To change this behavior you can set shouldFocus
to false
.