SensacionRC SensacionRC - 2 months ago 6
Javascript Question

ExtJS 4.2 two textfields in a form with same name

I have a form, and in the form there are two textfields with diferent itemIds but the same name, because when I call getForm().loadRecord(record) to fill the textfields in the form, only one is with data and the other is empty.

var form=new Ext.form.Panel({
itemId:'form1',
items:[
{
xtype : 'textfield',
fieldLabel :'textfield1',
name : 'value1',
itemId : 'textfield1',
readOnly:true
},
{
xtype : 'textfield',
fieldLabel :'textfield2',
name : 'value1',
itemId : 'textfield2'
}
]
});


The name property can only be used once in the same form to fill two diferent textfields with the same value from store?
I have search in the doc of sencha but didnĀ“t find anything about single use of name or unique name property.

Answer

Yes, the name property can only be used once in the same form. You can set value of second field by using

Ext.ComponentQuery.query('#textfield2')[0].setValue(YourValue);