-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow resetField() to set (or keep) the "initialValue" associated to a field #4755
Comments
Thanks for the kind words, I appreciate it. It should be behaving like this right now AFAIK, we have tests for that. Can you please create a simple demo for this? |
Sorry I misunderstood, so you want it to be able to set the initial value to possibly something different other than the current value? This feels a bit weird to me, but you can do so in two steps:
Does that work for you? Closing since it's not something I guess we should be doing, but feel free to explain your use-case and I will re-evaluate. |
Hi @logaretm, It would probably work, but
So the real problem is probably that Tell me if I'm wrong: if I could use |
I suppose we can expose
Depends on what you want to do, if you want to reset the initial value to something entirely different other than the current initial value then yes. If you want to "keep" the initial value and only change the current (non-initial) value then yes you would only need EDIT: exposed in ae3772a which should be tagged soon. |
Yes that's exactly what I need :) Thank you very much! :) |
I just realized I needed this, and here I come to find it was released just a few days ago. Thank you! |
Hi,
first of all thank you for your fantastic form validation library.
Actually, you cannot keep the current
initialValue
associated to a field while using theresetField()
method.Would it be possible to make the
resetField()
method evolve to be able to do something like:And later be able to easily do
$refs.formRef.resetForm()
to restore all initial values?Of course, my example is very simplified, but this new functionality would be very useful to me in my much more complex forms.
Fortunately, it looks like the changes needed are pretty straightforward if I look at the code in
useField.ts
:Thank you!
Thierry.
The text was updated successfully, but these errors were encountered: