Saturday, December 17, 2011

EXTJS ComboBox validation fails even when validation is turned off

When validationEvent is set to false and validateOnBlur is set to false on a Field (i.e. TextField or Combobox) then there should be no validation.

I found two cases where the Field validates when validation is turned off ...
1) When you use setValue on a TextField
2) When you select value in a combobox

The same can be fixed by overriding the setValue method:

Ext.override( Ext.form.Field, {
setValue : function(v){
this.value = v;
if(this.rendered){
this.el.dom.value = (Ext.isEmpty(v) ? '' : v);
if(this.validationEvent !== false || ((this.validateOnBlur || this.validationEvent === "blur") & this.hasFocus !== true ) ){
this.validate()
}
};
return this;
}
})