Replies: 2 comments
-
Agree. setValue can't always be used because accept value: UnpackNestedValue<FieldPathValue<TFieldValues, TFieldName>> so it can't be used because we need provide explicit value, rather that when we need to reset field, we actualy want be able to use something like setDefaultValue or resetTo value: UnpackNestedValue<FieldPathDefaultValue<TFieldValues, TFieldName>> |
Beta Was this translation helpful? Give feedback.
0 replies
-
@bluebill1049 you closed the original issue and marked as completed? Has this feature been added? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I could be missing something from the docs here, but I can't just reset a section or individual inputs of my form without resetting the whole form.
The docs for the
reset
function says:defaultValues
touseForm
in order to reset theController
components' value.But how do I tell which
Controller
values to reset, without resetting all of them? I tried with an array of input names, like howtrigger
works when validating, but it didn't work.So I tried removing all the
defaultValue
from myController
s. And added thedefaultValues
to myuseForm
method. I then tried ways of structuring object values to pass intoreset({ values: {...}})
, but my form has deeply nested objects in some sections and is dynamic and difficult to programmatically create.I think something like this would be easiest:
The alternative I'm using at the moment, is passing in
defaultValues
touseForm
and creating my ownonReset
function from thedefaultValues
object:Beta Was this translation helpful? Give feedback.
All reactions