Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating formwindow view to use errors returned from the server, same…

… as formpanel scaffold view
  • Loading branch information...
commit f9fecc2d4790d8554f26e2d1795941bd35860df3 1 parent 82d69da
@rdougan rdougan authored
Showing with 49 additions and 1 deletion.
  1. +1 −1  ext-mvc-all-min.js
  2. +24 −0 ext-mvc-all.js
  3. +24 −0 view/FormWindow.js
View
2  ext-mvc-all-min.js
1 addition, 1 deletion not shown
View
24 ext-mvc-all.js
@@ -5176,6 +5176,30 @@ ExtMVC.registerView('extmvc', 'formwindow', {
};
Ext.Window.prototype.initComponent.apply(this, arguments);
+
+ this.initListeners();
+ },
+
+ /**
+ * Sets up any listeners on related objects. By default this just listens to update-failed and create-failed
+ * events on the related controller and marks fields as invalid as appropriate
+ */
+ initListeners: function() {
+ if (this.controller) {
+ this.controller.on({
+ scope : this,
+ 'create-failed': this.showErrorsFromInstance,
+ 'update-failed': this.showErrorsFromInstance
+ });
+ }
+ },
+
+ /**
+ * Reads errors from a model instance and marks the relevant fields as invalid
+ * @param {ExtMVC.Model.Base} instance The model instance
+ */
+ showErrorsFromInstance: function(instance) {
+ this.form.getForm().markInvalid(instance.errors.forForm());
},
/**
View
24 view/FormWindow.js
@@ -79,6 +79,30 @@ ExtMVC.registerView('extmvc', 'formwindow', {
};
Ext.Window.prototype.initComponent.apply(this, arguments);
+
+ this.initListeners();
+ },
+
+ /**
+ * Sets up any listeners on related objects. By default this just listens to update-failed and create-failed
+ * events on the related controller and marks fields as invalid as appropriate
+ */
+ initListeners: function() {
+ if (this.controller) {
+ this.controller.on({
+ scope : this,
+ 'create-failed': this.showErrorsFromInstance,
+ 'update-failed': this.showErrorsFromInstance
+ });
+ }
+ },
+
+ /**
+ * Reads errors from a model instance and marks the relevant fields as invalid
+ * @param {ExtMVC.Model.Base} instance The model instance
+ */
+ showErrorsFromInstance: function(instance) {
+ this.form.getForm().markInvalid(instance.errors.forForm());
},
/**
Please sign in to comment.
Something went wrong with that request. Please try again.