PDA

View Full Version : 2x ComboBox Bugs



cgi-bin
3 Jul 2007, 7:32 AM
Bug1:
When using hiddenName, if you type in a value that is not one of the drop-down values (from store), it does not submit the typed in value, it submits either an empty value or whatever the last selected value was (see bug2).

Bug2:

Form has ComboBox, forceSelection is false.
Select a value
Change your mind and delete the value.
emptyText is again displayed
When submitted it sends the last value you selected


I tested this in 1.0.1a and 1.1-beta2


titleStore = new Ext.data.SimpleStore({
fields: ['value','text'],
data: [['Mr.','Mr.'], ['Ms.','Ms.'], ['Mrs.','Mrs.'], ['Miss','Miss']]
});

new Ext.form.ComboBox({
name: 'titleCB',
hiddenName: 'title',
fieldLabel: 'Title',
store: titleStore,
displayField: 'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: 'Type or Select...',
selectOnFocus: true
})

Jamie Avins
3 Jul 2007, 1:16 PM
Not sure if this is really a bug or just not being handled for you by Ext.

You have a displayField and a valueField. This creates a hidden input, that input is not cleared by 'blanking' the field.

I fix mine when I validate with:

combo.on('valid', function(field) {
if (field.getValue() == '') {
field.setRawValue('');
}
});

You could catch a different event or do it before you post.

violinista
4 Jul 2007, 11:37 PM
I think it MUST be fixed by setting a hiddenName property, and it's considered good practice among many Ext's developers. Go search forum with "combo hiddenName".

cgi-bin
5 Jul 2007, 5:03 AM
I fix mine when I validate with:

combo.on('valid', function(field) {
if (field.getValue() == '') {
field.setRawValue('');
}
});

This doesn't fix it... it is still submitting whatever the last selected value was if one was selected, if one was not selected and you try to type in a value, it just blanks the field.

I'll have to remove the emptyText config for now since that is why I was forced to use hiddenName field which I guess is bug #3.

Nullity
5 Jul 2007, 6:00 AM
Here is how I fixed Bug2:


Ext.form.ComboBox.prototype.onBlur = Ext.form.ComboBox.prototype.onBlur.createSequence(function() {
if (!this.store.getAt(this.view.getSelectedIndexes()[0]) || !this.getRawValue()) {
this.selectedIndex = -1;
if (this.hiddenField) {
this.hiddenField.value = '';
}
}
});