PDA

View Full Version : Bug? textfield inputId and id don't work together?



dobberph
6 May 2013, 3:22 AM
Hi,

I found this behaviour:
If I use in a form a textfield and set an inputId and also an id I always get the errormessage in console:
"Uncaught TypeError: Cannot read property 'length' of undefined"
In ext.all.js:21

Is this a bug?



Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',


initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'form',
bodyPadding: 10,
title: 'My Form',
method: 'GET',
url: 'app.html',
items: [
{
xtype: 'fieldcontainer',
formBind: true,
height: 120,
width: 400,
fieldLabel: 'Label',
items: [
{
xtype: 'fieldset',
height: 250,
width: 400,
title: 'My Fields',
items: [
{
xtype: 'checkboxfield',
anchor: '100%',
id: 'checker',
inputId: 'checker',
fieldLabel: 'Label',
boxLabel: 'Box Label'
},
{
xtype: 'textfield',
anchor: '100%',
id: 'texter',
inputId: 'texter',
fieldLabel: 'Label'
}
]
}
]
},
{
xtype: 'button',
handler: function(button, event) {
var form = this.up('form').getForm();
if (form.isValid()) {
// Submit the Ajax request and handle the response
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.message);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');
}
});
}
},
text: 'MyButton'
}
]
}
]
});
me.callParent(arguments);
}
});


Thanks,
Tobi

droessner
6 May 2013, 9:07 AM
The id of the component field and the id of the input field must be unique. You can't define the same id for both.

See http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.form.field.Text-cfg-inputId

(http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.form.field.Text-cfg-inputId)The id that will be given to the generated input DOM element. Defaults to an automatically generated id. If you configure this manually, you must make sure it is unique in the document.

dobberph
6 May 2013, 11:11 AM
I see.
It works now, thanks.

But: Its possible with checkboxes.
I have a checkbox in the above example.
There both is the same and it works.

Nevertheless thanks for the help,
Tobias