Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion addon/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ export default Em.Component.extend({

/*
Form submit

Optionally execute model validations and perform a form submission.
*/
submit: function(e) {
var promise;
var self = this;
if (e) {
e.preventDefault();
}
Expand All @@ -64,7 +65,21 @@ export default Em.Component.extend({
return _this.get('targetObject').send(_this.get('action'));
}
};
})(this)).catch((function(_this) {
// if the form don't valdiate.
// show errors on all fields.
self.showErrors(_this);
})(this));
}
}
// show errors on all child fields.
showErrors: function (view) {
var self = this;
jQuery.each(view._childViews, function (key, validation) {
validation.set('canShowErrors', true);
if (validation._childViews) {
self.showErrors(validation);
}
});
}
});