View Full Version : Custom attributes to ExtJS controls

28 Mar 2011, 9:06 PM
Hi ,

I want to know if there is any way to add a custome attribute to the HTML generated from Ext controls.

For example, a simple ExtJS TextField generates HTML like below,

<INPUT type=text name="txtNAME1" id="txtNAME1">

To this I want to add my own attribute (DisplayName) as below,

<INPUT type=text name="txtNAME1" id="txtNAME1" displayName="dspNAME1">

Thank you all for your replies.

29 Mar 2011, 2:30 AM
after a bit of research I found the solution. here is the complete code..

function fn3()
var txtBox = new Ext.form.TextField({
renderTo: 'myButton',
allowBlank: false,
blankText: 'last name is required',

var attribs = {myAttribute:'This is my attribute',
myAttribute2:'This is my attribute',myAttribute3:'This is my attribute'};

return txtBox;

2 May 2013, 8:28 AM
You could do it like this;
{xtype: 'textfield',
fieldLabel: 'search' ,
inputAttrTpl: 'foo=avalueForAttribute'

This will add an attribute 'foo' with a value 'avalueForAttribute'