-
-
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
form reset method is not there. #376
Comments
how to clear the whole form just like form.clear() is there any method in vee-validate |
I don't know what do you mean by clear, you can clear the errors using |
errors.clear() does not seem to work for me. I see the method and pass in the form name but does not clear out. |
@peteringram0 You need to wrap it in |
@logaretm It seems that at the moment, using methods: {
emptyForm() {
this.name = ''
this.email = ''
Vue.nextTick(() => {
this.errors.clear()
})
}
} Is there something I'm missing? |
I had same probelm, I validate form when submit it, after pass the validation, set value to null on each model, and errors appear. any suggestion ? thanks in advance. use this.errors.clear or this.errors.remove(field) not working for me, here's my code: axios.post(uri, this.inp).then(response => {
this.responseData = {
status: true,
message: 'Success'
}
for (var index in this.inp) {
this.inp[index] = null;
}
this.errors.clear();
}).catch(error => {
this.responseData = {
status: false,
message: 'Error'
}
}); |
@Etheryte I will try to implement a native fix for this, via an API method probably, since |
Any workaround/update for that issue on RC3? I reinstalled beta25 and it's working fine with |
@Finrod927 Please see: #480 (comment) |
@johnmerced Thanks, but I cannot make it work in my project ! |
I'm having this error in the same context as @ianfebriyanto describes here. My suspicion is what's happening in this case is that the errors are in fact being cleared, but then being set again because the field classes (ie 'pristine', 'dirty', 'touched' , 'untouched') are not being reset as well, and thus creating an error on an empty required field. Would an API method to expose ClassListener.reset() fix this? |
@andosteinmetz Sadly no, this issue is very problematic, because the issue is after setting your fields, Vue has not actually updated the DOM yet, when it does it triggers another validation which is way after you cleared the errors. The problem is that the updates are async, I tried adding A less than viable solution is to clear the error bag after a very small delay using |
I think that the pausing code you have currently should work with some minor changes. If you automatically pause the validator in the error clearing method and then add an automatic resume in the validation methods, I think it ought to work, since the validation should refire only once the fields have actually updated? Adding in a tick handler would ensure all validators cancel before resume is called. I haven't tested the approach myself, though. // In validators
if (this.paused) {
Vue.nextTick(() => {
this.resume();
});
return Promise.resolve(true);
} |
@Etheryte I will try your suggestion, thanks! |
So I spent a few hours on what it looked like a goose chase, now I feel stupid, so: After a lot of testing, it seemed like the model watchers were getting triggered too late, after the nextTick even. which doesn't make sense as normal watchers were getting the correct values in correct timings, it was all because of the New API method: this.$validator.clean(); Is just a wrapper around Updated fiddle: |
@johnmerced Its not released yet, I will see if I can finish documenting the changes and release one today. |
@logaretm Awesome - thank you! |
@logaretm the problem is still here and your approch seems not to work also the fiddle you provide does not reproduce the problem when commenting the line 12: |
@giammin The fiddle uses the latest commited js in master, some issues is still there, I've updated it to use rc.6 |
Adding a delay (via data-vv-delay) breaks this. Having a lot of trouble resetting a form with it :( |
Can confirm the issue with the delay that @gazugafan reported. |
Versions:
Description:
Steps To Reproduce:
The text was updated successfully, but these errors were encountered: