PDA

View Full Version : Checkbox with name - possible bug in input generation?



jadrake75
3 Mar 2013, 9:40 AM
I noticed that EXT-JS checkboxes when rendered with a name set were not outputting a name value in the input control. While they were posting successfully, the lack of the name makes it rather difficult to use things like selenium or other tools against the checkbox when key differentiating value is the name attribute. When looking at Checkbox.js it does not appear that it is using the name in the input rendering.

Using a simple override (below) I was able to get around this, but I am wondering if this is a bug or done on purpose?

EXT-JS Version 4.1.1a


Ext.define('Stampweb.overrides.form.field.Checkbox', { override: 'Ext.form.field.Checkbox',

fieldSubTpl: [
'<tpl if="boxLabel && boxLabelAlign == \'before\'">',
'{beforeBoxLabelTpl}',
'<label id="{cmpId}-boxLabelEl" {boxLabelAttrTpl} class="{boxLabelCls} {boxLabelCls}-{boxLabelAlign}" for="{id}">',
'{beforeBoxLabelTextTpl}',
'{boxLabel}',
'{afterBoxLabelTextTpl}',
'</label>',
'{afterBoxLabelTpl}',
'</tpl>',
'<input type="button" id="{id}" {inputAttrTpl} ',
'<tpl if="tabIdx"> tabIndex="{tabIdx}"</tpl>',
'<tpl if="name"> name="{name}"</tpl>',
'<tpl if="disabled"> disabled="disabled"</tpl>',
'<tpl if="fieldStyle"> style="{fieldStyle}"</tpl>',
' class="{fieldCls} {typeCls}" autocomplete="off" hidefocus="true" />',
'<tpl if="boxLabel && boxLabelAlign == \'after\'">',
'{beforeBoxLabelTpl}',
'<label id="{cmpId}-boxLabelEl" {boxLabelAttrTpl} class="{boxLabelCls} {boxLabelCls}-{boxLabelAlign}" for="{id}">',
'{beforeBoxLabelTextTpl}',
'{boxLabel}',
'{afterBoxLabelTextTpl}',
'</label>',
'{afterBoxLabelTpl}',
'</tpl>',
{
disableFormats: true,
compiled: true
}
]
});

mitchellsimoens
5 Mar 2013, 8:12 AM
Do notice that it's a button not a checkbox. You can accomplish this without extending or overriding via:


{
xtype : 'checkboxfield',
fieldLabel : 'Foo',
name : 'foo',
inputAttrTpl : 'name="foo"'
}