View Full Version : Add markup to a component

14 Aug 2014, 10:08 AM
How to you add a property to a new component, which is then rendered into the control? For example if I wanted to add myProperty="something", this doesn't seem to work:

Ext.define("John.TextArea", {
extend: "Ext.form.field.TextArea",
alias: "widget.johnarea",

myProperty: '', // this is new
fieldSubTpl: [
'<textarea id="{id}" {inputAttrTpl}',
'<tpl if="name"> name="{name}"</tpl>',
'<tpl if="myProperty"> myproperty="{myProperty}"</tpl>', // This is new
'<tpl if="rows"> rows="{rows}" </tpl>',
'<tpl if="cols"> cols="{cols}" </tpl>',
'<tpl if="placeholder"> placeholder="{placeholder}"</tpl>',
'<tpl if="size"> size="{size}"</tpl>',
'<tpl if="maxLength !== undefined"> maxlength="{maxLength}"</tpl>',
'<tpl if="readOnly"> readonly="readonly"</tpl>',
'<tpl if="disabled"> disabled="disabled"</tpl>',
'<tpl if="tabIdx"> tabIndex="{tabIdx}"</tpl>',
' class="{fieldCls} {typeCls} {inputCls}" ',
'<tpl if="fieldStyle"> style="{fieldStyle}"</tpl>',
' autocomplete="off">\n',
'<tpl if="value">{[Ext.util.Format.htmlEncode(values.value)]}</tpl>',
disableFormats: true

I'm on Ext 4.2.1

14 Aug 2014, 4:00 PM
See getSubTplData.