PDA

View Full Version : FormPanel Submit, getForm error



A387
17 Oct 2011, 1:50 AM
Dear forumusers,

I'm getting this error: Uncaught TypeError: Object [object Object] has no method 'getForm' when I try to submit a form. The code is below. Does any of you see the problem?


var formPanel = new Ext.form.FormPanel({ id: 'frm-write',
scroll: 'vertical',
title: 'Reageer',
iconCls: 'compose',
items: [
{
xtype: 'fieldset',
defaults: {
labelAlign: 'left',
required: true
},
items: [
{
xtype: 'textfield',
name : 'naam',
label: 'Naam',
autoCapitalize: true
},
{
xtype: 'textareafield',
name : 'bericht',
label: 'Bericht',
},
{
xtype: 'button',
text: 'Verzenden',
scope: this,
handler: function(){
formPanel.getForm().submit({

});
}
}
]
}
]
});

ferengidedalo
17 Oct 2011, 3:59 AM
yes, inside the scope of the handler fompanel thas not exist, look in the docs, the handler receives parameters with a pointer to the panel, you should use that parameter of the handler to get a reference of the panel and call getForm there...

the click event receives 2 parameters, the button itself and the event.

this should work:



handler: function(btn,event){
// gets the panel this button is part of
var myForm = btn.up('formpanel');

myForm.getForm().submit({ });
}