PDA

View Full Version : [CLOSED][3.0.3] NumberField -> allowBlank = false marking invalid on reset



tobiu
7 Dec 2009, 11:23 AM
hi together,

i am a bit stuck with this one. it seems like a bug, though i am not sure for total.
see this little example:



Ext.onReady(function() {

Ext.ns('app');

app.win = new Ext.Window({
width : 400
,height : 400
,items :
app.form = new Ext.form.FormPanel({
labelWidth : 175
,items : [
new Ext.form.TextField({
allowBlank : false
,fieldLabel : 'textField'
,name : 'textField'
})
,new Ext.form.NumberField({
allowBlank : false
,fieldLabel : 'numField'
,name : 'numField'
})
]
})
});

app.form.getForm().reset();
app.win.show();
});


created with ff3 and ext-3.0.3

when calling form.reset(), the text-field keeps clean, the numberField does not. i watched quite a long time into the code, but have not found any difference yet to older and working versions of the bib (it at least worked in ext-3.rc2...).

thanks for your help,
tobiu

tobiu
7 Dec 2009, 11:54 AM
i found out, that the setValue-method is causing trouble.



Ext.override(Ext.form.NumberField, {
setValue : function(v){
if(!Ext.isEmpty(v)){
v = typeof v == 'number' ? v : parseFloat(String(v).replace(this.decimalSeparator, "."));
v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
}
return Ext.form.NumberField.superclass.setValue.call(this, v);
}
});


seems to work, though i am not sure, if this is a good starting point.

any ideas would be great!

kind regards,
tobiu

tobiu
16 Dec 2009, 12:55 AM
could someone move this to bugreports please?

kind regards,
tobiu

tobiu
21 Dec 2009, 12:04 AM
thanks for moving!

kind regards,
tobiu

evant
21 Dec 2009, 3:45 AM
Because the field isn't rendered yet, so clearInvalid doesn't work.



Ext.onReady(function(){

Ext.ns('app');

app.win = new Ext.Window({
width: 400,
height: 400,
items: app.form = new Ext.form.FormPanel({
labelWidth: 175,
items: [new Ext.form.TextField({
allowBlank: false,
fieldLabel: 'textField',
name: 'textField'
}), new Ext.form.NumberField({
allowBlank: false,
fieldLabel: 'numField',
name: 'numField'
})]
})
});

app.win.show();
(function(){
app.form.getForm().reset();
}).defer(5000);
});

tobiu
21 Dec 2009, 4:08 AM
hi evant,

it should not be a problem of clearInvalid(), because the field was never marked as invalid. since form.reset() works for all not rendered form-elements except of numberField and that element worked too on 3.0-rc2, you might want to look at my fix-suggestion for the setValue-method. i tested it quite much and it works fine.

kind regards,
tobiu