PDA

View Full Version : Submit form with other post params



Mycoding
16 Jan 2011, 11:08 PM
Please give me advice is it possible to submit form and send another params.
I tried to do like this



panel.getForm().submit({
url:url,
baseParams:params,
waitMsg:'Saving data...',
....


And this



panel.getForm().submit({
url:url,
params:params,
waitMsg:'Saving data...',
....


All I got form this way is add addiotiononal params. But I need to send only my needed params but not all
form params.

I think about Ext.Ajax and Ext.Connection but I need Mask in Form and Don't know how to do mask in form without
submitting form.

Condor
17 Jan 2011, 12:44 AM
The form has a 'baseParams' config option and the submit() method has a 'params' option, so only your second example is correct.

Also, 'baseParams' must be an object, while 'params' can be either an object or a URL encoded string.

Mycoding
17 Jan 2011, 1:04 AM
I do so


panel.getForm().submit({
url:url,
params:params,

But all form's params are sent
params is object.

Here is code



function sendNewUserParams(params,url){
panel.getForm().submit({
url:url,
params:params,
waitMsg:'?????????? ??????...',
success: function(form, action){
Ext.Msg.show({
title:'????? ???????',
msg:'?????? ?????????',
width:200,
iconCls:'icon-done',
buttons: Ext.Msg.OK
});
},
failure: function(form, action){
if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
Ext.Msg.show({
title:'?????? ??????????',
msg:'??????:'+action.response.status+': '+action.response.statusText,
width:200,
iconCls:'icon-notdone',
buttons: Ext.Msg.OK
});
}
if (action.failureType === Ext.form.Action.SERVER_INVALID){
Ext.Msg.show({
title:'??????',
msg:'????? ???????:'+action.result.error,
width:200,
iconCls:'icon-notdone',
buttons: Ext.Msg.OK
});
}
}
});
}


And here is how I run it


if(btn=='yes'){
var params={parol:oldParol,newParol:newParol},
url="request/user-action/save-new-private-parol.php";
sendNewUserParams(params,url);
}

Condor
17 Jan 2011, 2:03 AM
A submit will always send the all form field values. If you don't want that, then you should be using Ext.Ajax.request and not a form method.

Mycoding
17 Jan 2011, 2:11 AM
But if so.
Is the way to do mask af loading in form?
I tryed to find some methods that do mask in form and didn't find.

Condor
17 Jan 2011, 2:17 AM
The loadmask is activated by beforeAction/afterAction.

You could either show a loadmask yourself (see the beforeAction/afterAction code) or you could register your own action in Ext.form.Action.ACTION_TYPES and call doAction.

valititi
17 Jan 2011, 2:19 AM
and if you still want to use ONLY some form submit... Then...
You can create a function which create ANOTHER form !!! Adding dom elems for a second form. You will put there only the fields you need to submit... then sumbit this second form (which can contains practically only some hidden fields you want to submit (but must have a function form this who takes fields vals from first form and put it in another)... This only if you need to use FORM.SUBMIT. :-) Otherwise and this is 98% easier is to made how Condor already tell you
:-)

Condor
17 Jan 2011, 2:24 AM
I don't see why you would ever want to do that (well, unless you are doing file uploads - for that you indeed need an actual <form>).

Mycoding
17 Jan 2011, 2:59 AM
Thanks to all.
I will try.