Replies: 2 comments
-
|
not to mention that setting form values in bulk inside a method named "reset()" does not really sounds like it is a correct thing to do, its not very intuitive and makes you think twice about it being the correct thing to do or not since you just wanted to set the form values and not anything more than that. i do not foresee why they do not have a |
Beta Was this translation helpful? Give feedback.
-
|
I also found the type-safety of reset to be weak. So, I ended up spinning up my own function that adds full type-safety to the payload and allows for the setValue options to be supported, as well as a custom option for only updating empty values (if the form value already exists, don't overwrite it. This was needed for my use-case). All the code does is loop through an type-safe object's keys and run the setValue on each key value pair. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there, I have a form here and its quite peculiar.. like a calculator. My problem is the following:
User can update some number inputs A, B or C and on the blur I need to call some API that will return new values for many other fields (lets call them calculated fields) D, E, F, G etc based on A , B or C values. I want to update my form with those values but I do NOT want to set those updated fields as
dirtybecause the user hasn't manually changed them it was a system update (yes, triggered by the user but my point stills, I dont want them dirty.. I need to have control over the field state and to know if user changed it manually or not)My current workaround is setting each calculated field individually with
{ shouldDirty: false }but that is ugly and seems pretty weird.Is there any reason why we don't have a bulk
setValuesor an option to NOT re-evaluate theisDirtywhen callingreset?Beta Was this translation helpful? Give feedback.
All reactions