1
votes

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.

2
Can you please create a fiddle for this and show where you exactly getting stuck.UDID

2 Answers

3
votes

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);
3
votes

Try with 'mapping' in model

MODEL:

  fields: [
    {name: 'value1',  type: 'string'},
    {name: 'valueSameAs1',  type: 'string', mapping: 'value1'}
  ]


VIEW:

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

Take a look at:

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Field-cfg-mapping

and

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Field-cfg-convert