PDA

View Full Version : Form submit() doesn't submit values



alphadogg
16 Sep 2012, 10:40 AM
I have a form that, when I call submit() on it, seems to ignore the values in the form.



, handler: function() {
var frm = this.up('form').getForm();
if (frm.isValid()) {
var flds = frm.getValues();
// submit form
var gd = Ext.getCmp('addServiceForm_SrcGrid').getValue();
if( gd == 'expectedGrid' ){
frm.submit({
url: 'addExpectedService_single.asp'
, clientValidation: false
, standardSubmit: true
, 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');
}
});
}
if( gd == 'originalGrid' ){
frm.submit({
url: 'addOriginalService_single.asp'
, standardSubmit: true
});
}

// reset form for next turn
this.up('form').getForm().reset();
this.up('window').hide();
}
}


On the receiving end, I see nothing. I do get a request, but the values are the emptyText value for some fields, others are blank. Weirdly, the flds object does contain the actual field values.

What?

metalinspired
16 Sep 2012, 12:09 PM
What are you using as "receiving end"?
I had a same problem first time I used ExtJS in combination with Zend.
The deal was that I had to get the raw data that was submitted and than decode JSON string.

scottmartin
16 Sep 2012, 2:39 PM
To clarify this, the form is sent, but you cannot capture on the server side?

Scott.

vietits
16 Sep 2012, 6:08 PM
Try to remove or comment out the code of resetting form. The resetting action may happen before the form has been submitted. You can reset form on window open instead.


, handler: function() {
var frm = this.up('form').getForm();
if (frm.isValid()) {
var flds = frm.getValues();
// submit form
var gd = Ext.getCmp('addServiceForm_SrcGrid').getValue();
if( gd == 'expectedGrid' ){
frm.submit({
url: 'addExpectedService_single.asp'
, clientValidation: false
, standardSubmit: true
, 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');
}
});
}
if( gd == 'originalGrid' ){
frm.submit({
url: 'addOriginalService_single.asp'
, standardSubmit: true
});
}

// reset form for next turn
// this.up('form').getForm().reset();
this.up('window').hide();
}
}

alphadogg
16 Oct 2012, 12:43 PM
Changed the handler to use an AJAX call:



, handler: function() {
var frm = this.up('form').getForm();
if (frm.isValid()) {
// before getting values, re-enable addServiceForm_ServiceCode if in edit mode
Ext.getCmp('addServiceForm_ServiceCode').enable();
var flds = frm.getValues();
// save current vnd account and contract nbs to cookie
Ext.util.Cookies.set('addServiceForm_VndActNb', flds.vndActNb);
Ext.util.Cookies.set('addServiceForm_VndCntNb', flds.vndCntNb);
// call add/update AJAX page
Ext.Ajax.request({
url: 'addService_single.asp' //( flds.mode == 'add' ? 'addService_single.asp' : 'editService_single.asp')
, params: flds
, success: function(response, opts){
if( response.responseText != '' ) {
var jsonResp = Ext.decode(response.responseText);
if( jsonResp.success ){
Ext.getCmp(flds.srcGrid).getStore().load();
Ext.Msg.alert("SUCCESS","Done.");
}
else {
Ext.Msg.alert("ERROR", jsonResp.message + " Try again or cancel out.");
return false;
}
}
else {
Ext.Msg.alert("ERROR", "No response.");
return false;
}
}
, failure: function(response, opts){
Ext.Msg.alert("ERROR", "Grid failed to communicate with database. Try again or cancel out.");
return false;
}
});
// reset form for next turn
return false;
//this.up('form').getForm().reset();
//this.up('window').hide();
}
}