Closed rafaellupo closed 8 years ago
Thanks. I aim for simplicity :)
I intend to add a reset
method in the near future.
In the meantime, The reason why you get the required
error is that when you clear the value, the field becomes dirty, and this is exactly the combination that triggers the required
message.
To avoid this you need to explicitly set dirty
to false
:
this.$refs.myField.dirty = false
@matfish2 Great ! I added the method here, it worked fine ! One other great feature to implement is a form bulk setter. I have implemented that doing the following: I get the setter object keys, and fetch the fields that match the keys using the getField method. If is there a field, I call field.setValue, if there isn't a field I merge with additionalPayload. This way I could get my use case very well done. Regards !
Interesting. I'll think about it.
@matfish2 just for reference on what I did.
module.exports = function(data){
let keys = Object.keys(data);
let ap = this.options.additionalPayload;
keys.forEach( (val) => {
let field = this.getField(val);
if(field){
field.setValue(data[val]);
}else{
ap[val] = data[val];
}
});
}
Hi I wish to know, how can I reset one form. For example, I have a modal form. When I close the form modal it's supposed to reset all fields. But when I reset the fields values, the errors (required) keep showing on. By the way I really loved your component, it's really clean when compared to the other I was using (vue-validator)