PDA

View Full Version : Intercept validations



seek
7 Mar 2011, 12:26 AM
Hi all,
I have a little problem with validations. :))
I need to intercept validation on an Ext.form.TextField, in order to re-validate other textfields (some with remote validation).
What is the right event to intercept?

Thanks again to the forum
Seek

seek
15 Mar 2011, 2:23 AM
Solved with a plugin ;-)



Ext.ux.plugins.dependValidator = Ext.extend(Object, {
constructor: function(config){
config = config || {};
if(!config.id){
config.id = Ext.id();
};
Ext.apply(this, config);
},
init: function(field){
Ext.apply(field, {
conditions: this.conditions,
setCmpDep: function(cmp){
if(!field.depComp){field.depComp = new Array();};
field.depComp.push(cmp);
},
getCmpDep: function(){
return field.depComp;
},
changeVal:function(fld,nVal,oVal){
if(field.getCmpDep()){
Ext.each(field.getCmpDep(), function(itm,idx,all){
if(itm.plugins.length>0){
Ext.each(itm.plugins, function(it, id, al){
//remote validator support
if(it.constructor.ptype=="remoteval"){
this.forceRemoteValidation();
};
}, itm);
};
itm.validate();
}, field);
};
},
createDep: function(){
if(field.conditions){
var z=field;
Ext.each(field.conditions, function(itm,idx,a){
var v=Ext.getCmp(itm.comp);
if(v){
v.setCmpDep(z);
};
}, field);
};
}
});
field.on({
render: {
single: true,
scope: field,
fn: function(){
this.createDep();
this.el.on('change', this.changeVal, this);
}
}
});
}
});
Ext.preg('dependval', Ext.ux.plugins.dependValidator);