]>
git.proxmox.com Git - extjs.git/blob - extjs/examples/kitchensink/classic/samples/view/form/CustomErrorHandlingController.js
1 Ext
.define('KitchenSink.view.form.CustomErrorHandlingController', {
2 extend
: 'Ext.app.ViewController',
3 alias
: 'controller.form-customerrors',
5 submitRegistration: function() {
6 var form
= this.getView().getForm();
8 /* Normally we would submit the form to the server here and handle the response...
10 clientValidation: true,
12 success: function(form, action) {
15 failure: function(form, action) {
23 Ext
.Object
.each(form
.getValues(), function(key
, value
){
24 out
.push(key
+ '=' + value
);
26 Ext
.Msg
.alert('Submitted Values', out
.join('<br />'));
30 updateErrorState: function(cmp
, state
) {
32 errorCmp
= me
.lookupReference('formErrorState'),
33 view
, form
, fields
, errors
;
36 form
= view
.getForm();
38 // If we are called from the form's validitychange event, the state will be false if invalid.
39 // If we are called from a field's errorchange event, the state will be the error message.
40 if (state
=== false || (typeof state
=== 'string')) {
41 fields
= form
.getFields();
44 fields
.each(function(field
) {
45 Ext
.Array
.forEach(field
.getErrors(), function(error
) {
46 errors
.push({name
: field
.getFieldLabel(), error
: error
});
50 errorCmp
.setErrors(errors
);
51 me
.hasBeenDirty
= true;
52 } else if (state
=== true) {
57 onTermsOfUseElementClick: function(e
) {
60 target
= e
.getTarget('.terms');
64 this.lookupReference('termsOfUseWindow').show();
68 acceptTermsOfUse: function() {
69 this.closeTermsOfUse(true);
72 declineTermsOfUse: function() {
73 this.closeTermsOfUse(false);
76 closeTermsOfUse: function(accepted
) {
77 this.lookupReference('termsOfUseWindow').close();
78 this.lookupReference('acceptTerms').setValue(accepted
);