PDA

View Full Version : Dynamically change name or id of textfield



bradjen
4 Apr 2011, 2:31 AM
Is there any way that I can dynamiclly change name or id attribute of textfield. My idea is to dynamically add fileds to form but I need to shange their name attribute because later I need to submit that form to backend proccesing

somethingForm.OneHolidayRowConfig = {
xtype: 'textfield',
fieldLabel: '',
width:120,
allowBlank:false
};

for (i = 0; i < count; i++)
{

fieldID = 'someID' + i;
oneRow = new Ext.form.DateField(somethingForm.OneHolidayRowConfig);
Ext.getCmp('form').add( oneRow);
Ext.getCmp('form').doLayout();
oneRow.id = fieldID;
oneRow.name = fieldID;
oneRow.label.update(labelValue);
oneRow.setValue(dateValue);
};

bradjen
6 Apr 2011, 1:31 AM
If someone needed sometime, solution is to change name or id before you render that filed to the form

coshmos
10 Aug 2016, 4:56 AM
You can use "inputEl" of a component to change it's name. For example: someTextfield.inputEl.dom.name = 'new name'.