Open karellm opened 9 years ago
Hi @karellm, I hope you've figured this out by now, but in case you haven't I ran across the same issue, and this is how I solved it
actions: {
saveInvite: function() {
var self = this;
var onSaveSuccess = function(response) {
// ...
};
var onSaveFailure = function(response) {
var errors = response.errors
var errorKeys = Object.keys(errors);
for (var i = 0; i < errorKeys.length; i++) {
var s = 'errors.' + errorKeys[i];
self.model.set(s, [errors[errorKeys[i]]]);
}
};
self.model.save().then(onSaveSuccess, onSaveFailure);
}
}
In a nutshell, I get the errors back from the server, and then get the error keys from Object.keys(errors)
, then I loop through the errors and add them to the model by hand.
Note that in model.set('errors.email', ['Email is already taken'])
I pass an array because otherwise the validation message is nill.
Thanks @xcskier56 I will try that. I actually think I will go with easy form though as soon as they roll the v2.
I have a signup form, that performs some validation on the server (is the email already taken). When I get the server response, I set a flad
emailTaken
and run an inline validator:So the validation runs fine but the form doesn't re-render. Can I do that manually, or bind it to the validation?