PDA

View Full Version : wrong result form.isValid() when Ext.form.ComboBox has focus



mdissel
26 Sep 2007, 10:15 AM
I've got a form with a combobox (with forceselection=true), when the user tabs through the form everything is ok, but when the user enters a wrong value in the Ext.form.ComboBoxand uses the mouse to press a button it seems that the blur event is not triggered on the Ext.form.ComboBox, resulting in a form.isValid() = true..

I've implemented a workaround to move the focus to another control just before calling form.isValid(), but maybe this can be tackled in the control itself.. (i'm not sure if it's a Ext.form.ComboBox only problem)

Thanks

Marco

mdissel
27 Sep 2007, 6:59 AM
After some deeper investigation it seems that the blur event is not triggered when the mouse is used to click on a button (tested with IE 6, FF seems to work correctly). My workaround currently is to manually force a doForce on all the comboboxes... Here's my code to force users to select a value from a combobox.

// clear value when clearing the text of a combobox (when forceselection is true)

Ext.override(Ext.form.ComboBox, {
doForce: function() {
if(this.el.dom.value.length > 0){
if (this.el.dom.value == this.emptyText) {
this.clearValue();
}
else {
this.el.dom.value = this.lastSelectionText === undefined ? '' : this.lastSelectionText;
this.applyEmptyText();
}
} else {
this.reset();
this.clearValue();
}
}
});

// before calling form.isValid()
form.items.each(function(f){
if(f.doForce && f.forceSelection){
f.doForce();
}
});