PDA

View Full Version : BUG in FormPanel - fields are not properly constructed



radubrehar
24 Jan 2011, 7:50 AM
Hi,

I have found a serious bug in FormPanel. Reproduces in both Ext 3.3.0 and 3.3.1.

Run the following code on the ExtJS examples page:

var form;
var w = new Ext.Window({
height: 400,
width: 700,
layout: 'fit',
items: form = new Ext.form.FormPanel({
labelWidth: 200,
defaults: {
xtype: 'textfield',
autoCreate: {tag: 'input', type: 'text', autocomplete: 'off', maxlength: '90'},
width: 300
},
items: [
{
fieldLabel: 'City',
name: 'contactCity'
},
{
fieldLabel: 'First Address',
name: 'firstContactAddress'
},
{
xtype: 'textfield',
fieldLabel: 'Second Address',
name: 'secondContactAddress'
},

{
fieldLabel: 'Country',
name: 'contactCountry'
}
]
})
});

w.show();
form.getForm().setValues({
contactCity: 'Los Angeles',
firstContactAddress: 'address one',
secondContactAddress: 'address two',
contactCountry: 'USA'
});

The code should populate all fields in the formpanel with values. Instead, some fields remain empty.
If you use Firebug to inspect form fields, and get a reference to one of the fields that remained empty (var field = Ext.getCmp(...) ), just output to the console the element associated to the field (field.el) and you'll see the associated element is not the correct one. Event doing an Ext.getCmp(....).setValue(...) sets the value to a different field (probably the last one).

Thanks

Condor
24 Jan 2011, 8:51 AM
'autoCreate' needs to be a unique object for each instance, so you can't specify it in 'defaults'.

Change 'autoCreate' to 'defaultAutoCreate'.

radubrehar
25 Jan 2011, 12:30 AM
Thanks Condor! The docs are silent about this, so thanks for sharing! It works this way!