PDA

View Full Version : [FIXED][3.x] FormPanel modifies initialConfig



Condor
15 Jun 2009, 11:31 PM
FormPanel.createForm removes the listeners from the initialConfig object. This makes it impossible to create another form (with listeners) from the same config object.

Example:

Ext.onReady(function() {
var formCfg = {
title: 'Test form',
width: 500,
height: 300,
items: {
xtype: 'textfield',
fieldLabel: 'Text'
},
listeners: {
render: function(c){
console.log('render called on form ' + c.id);
}
}
};
var form1 = new Ext.form.FormPanel(Ext.apply({id: 'form1'}, formCfg));
form1.render(Ext.getBody());
form1.destroy();
var form2 = new Ext.form.FormPanel(Ext.apply({id: 'form2'}, formCfg));
form1.render(Ext.getBody());
});
(the render event for form2 won't be called)

I suggest changing:

Ext.override(Ext.form.FormPanel, {
createForm : function(){
var config = Ext.apply({listeners: {}}, this.initialConfig);
return new Ext.form.BasicForm(null, config);
}
});

evant
15 Jun 2009, 11:37 PM
Fixed, both branches.

jay@moduscreate.com
16 Oct 2009, 9:41 AM
I realize that I am resurrecting an old thread but...

Why create an empty object? In the interest of more efficient code, why not just pass null?

var config = Ext.apply({listeners: null}, this.initialConfig);