fix validate returning the wrong thing on success, remove error messages on successful validate
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
index a04fd8f..417132d 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -72,17 +72,22 @@
validate: function(attrs, options) {
errors = {};
+ foundErrors = false;
_.each(this.validators, function(validatorList, fieldName) {
_.each(validatorList, function(validator) {
if (fieldName in attrs) {
validatorResult = validateField(validator, attrs[fieldName])
if (validatorResult != true) {
errors[fieldName] = validatorResult;
+ foundErrors = true;
}
}
});
});
- return errors;
+ if (foundErrors) {
+ return errors;
+ }
+ // backbone.js semantics -- on successful validate, return nothing
}
});
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index dc66e45..2fa9554 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -268,6 +268,8 @@
var that = this;
var isNew = !this.model.id;
+ this.$el.find(".help-inline").remove();
+
/* although model.validate() is called automatically by
model.save, we call it ourselves, so we can throw up our
validation error before creating the infoMsg in the log
@@ -369,7 +371,6 @@
},
onFormDataInvalid: function(errors) {
- this.$el.find(".help-inline").remove();
var self=this;
var markErrors = function(value, key) {
console.log("name='" + key + "'");