stever
2 Jul 2009, 1:17 PM
Is there a reason why the logic is different between the two functions for adding fields to the basicForm?
// private
initFields : function(){
var f = this.form;
var formPanel = this;
var fn = function(c){
if(formPanel.isField(c)){
f.add(c);
}if(c.isFieldWrap){
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
f.add(c.field);
}else if(c.doLayout && c != formPanel){
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
//each check required for check/radio groups.
if(c.items && c.items.each){
c.items.each(fn, this);
}
}
};
this.items.each(fn, this);
},
// private
onAdd : function(ct, c) {
// If a single form Field, add it
if (this.isField(c)) {
this.form.add(c);
// If a Container, add any Fields it might contain
} else if (c.findBy) {
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
this.form.add.apply(this.form, c.findBy(this.isField));
}
},
// private
initFields : function(){
var f = this.form;
var formPanel = this;
var fn = function(c){
if(formPanel.isField(c)){
f.add(c);
}if(c.isFieldWrap){
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
f.add(c.field);
}else if(c.doLayout && c != formPanel){
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
//each check required for check/radio groups.
if(c.items && c.items.each){
c.items.each(fn, this);
}
}
};
this.items.each(fn, this);
},
// private
onAdd : function(ct, c) {
// If a single form Field, add it
if (this.isField(c)) {
this.form.add(c);
// If a Container, add any Fields it might contain
} else if (c.findBy) {
Ext.applyIf(c, {
labelAlign: c.ownerCt.labelAlign,
labelWidth: c.ownerCt.labelWidth,
itemCls: c.ownerCt.itemCls
});
this.form.add.apply(this.form, c.findBy(this.isField));
}
},