PDA

View Full Version : compositefield / markInvalid a field, but form valid is true



3xc3ption
15 Dec 2010, 4:26 AM
Hi there,

i have a problem with the compositefield (version 3.3.1). First the code


myTime_Field = Ext.extend(Ext.form.CompositeField, {
allowBlank: true,
layout: 'hbox',
fieldLabel: 'from until',
initComponent: function() {
this.items = [
{
xtype: 'datefield',
flex: 1,
name: 'datum_1',
ref: 'date1'
},
{
xtype: 'datefield',
name: 'datum_2',
flex: 1,
ref: 'date2'
}
];
myTime_Field.superclass.initComponent.call(this);
this.on('beforerender', this.configFields, this);
this.date1.on('change', this.dateValidation, this);
this.date2.on('change', this.dateValidation, this);
},
'configFields': function(){
if(this.allowBlank == false){
this.date1.allowBlank = false;
this.date2.allowBlank = false;
}
},
'dateValidation': function(obj, func){
this.date2.markInvalid('Error');

}
} );
Ext.reg('my_time_field', myTime_Field);


TestUi = Ext.extend(Ext.form.FormPanel, {
title: 'My Form',
width: 400,
height: 318,
padding: 10,
initComponent: function() {
this.items = [
{
xtype: 'my_time_field',
ref: 'zeitraum'
},{
xtype: 'vos_btn_save_ui',
ref: 'save_btn'
}
];
TestUi.superclass.initComponent.call(this);
}
});
Ext.onReady(function() {
var headPanel = new Tester({
renderTo: 'panel_test_1'
});
headPanel.render();
});


when i set the property "allowBlank:false", then is the "return of this.getForm().isValid()" false. that is correct.
when i switch "allowBlank:true" and use "this.date2.markInvalid('Error');" then is value from "this.getForm.isValid()" true, but that is not correct, because the field is marked as invalid!?

where is problem ... :-?

ewgoforth
9 Jun 2011, 9:41 AM
Did you ever get an answer to your question?