PDA

View Full Version : How to create a submit button for a form when extendin FormPanel



ipreti
17 Sep 2009, 5:49 AM
Hi guys,
Im trying to extend a FormPanel and to setup some fields and "reset" and "submit" button to it.
The problem is, i've always used the sintax :


form = new FormPanel();
form.getForm().submit();

to do it, but now i dont have the form variable to to so.

the code is as below:



ClusterForm = function(){


ClusterForm.superclass.constructor.call(this, {


buttons:[{
text: 'Submit',
handler: function(form) {
???????????????.submit()({
url:'cluster.smart',
waitMsg:'Saving Data...',
params: {
cmd: "save"
},
success: function(form, action) {
Ext.MessageBox.alert(action.result.success, action.result.msg);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.MessageBox.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.MessageBox.alert('Failure', 'Ajax communication failed');
break;
default:
Ext.MessageBox.alert(action.result.msg, action.result.msg);


}
}
});
}
}]



}

}
Ext.extend(ClusterForm,Ext.FormPanel);


How can i get the current form from inside the submit handling ??

Thanks in advance!
Regards.
Ivan

aconran
17 Sep 2009, 6:37 AM
In your button configuration which has text and handler, additionally pass a scope of this.

You can then use this instead of ?????

ipreti
17 Sep 2009, 9:15 AM
buttons:[{
text: 'Submit',
scope:this,
handler: function(this) {
this.submit()({
url:'cluster.smart',
waitMsg:'Saving Data...',
params: {
cmd: "save"
}

17 Sep 2009, 9:26 AM
this.submit()({
should be:

this.getForm().submit({ ... options ... });