PDA

View Full Version : Submit 3 forms with one button in a ViewPort



Clever Cutter
17 Aug 2009, 8:43 AM
I have 3 forms in 1 viewport. Center and East panels have data forms, and a 3rd South form has a summary/comments section. Each form is independent with their own IDs. What I want is when the user submits the South's summary form, for the other 2 East/Center forms to submit as well. What I'm trying to do is call the save handlers for the East/Center forms on the save handler for the south form. The code for the South's form handler is:



var fm = this.getForm();
if (fm.isValid()) {
fm.submit({
clientValidation: true,
scope: this,
params: {loadnext: false},
success: function(form, result) {
var Response = Ext.decode(result.response.responseText);
if (Response.success===true) {

Ext.getCmp('form-center').saveData();
Ext.getCmp('form-east').saveData();

Ext.getCmp('grid-orders').setRowIndex(Ext.getCmp('id_wq_rowindex').getValue());
Ext.getCmp('grid-orders').getStore().reload();
} else {
this.updateStatus(Response.message);
}
},
failure: function(form, result) {
var Response = Ext.decode(result.response.responseText);
this.updateStatus(Response.message);
}
});
}


This is not working as I'd expect. When observing the FF console I don't even see the ajax call's to the Ext.getCmp('form-center').saveData(); and Ext.getCmp('form-center').saveData(); URLs.

Is there something I'm missing here? the East/Center saveData functions are standard fm.getForm.submits like above so I didn't include that code.

Animal
17 Aug 2009, 11:37 AM
You are calling the save handlers for the other forms only if the south form returned a success status. Is it returning a success value?

Set a breakpoint at



var Response = Ext.decode(result.response.responseText);


BTW, that's redundant, the decoded object is available. The second parameter is the Ext.form.Action.Submit object which is performing the Submit. That has in it the decoded object in its result property.

Clever Cutter
17 Aug 2009, 12:05 PM
Thanks Animal. I realize about the redundant code, I copied some boiler plate code instead of my real code and I guess that stuff is out dated. Anyway, I fixed this issue. I guess I should have coped my saveData functions from the other scripts because you would have seen my "clientValidation: true". I am trying to save these forms without clientValidation in this example and so I simply had to pass that as false to the submit() call so I could submit with missing data. Again, thank you for the assistance!