PDA

View Full Version : Passing some fields changed in submit...



wolverine4277
27 Jul 2007, 3:14 PM
I have a form with 4 fields (say a, b, c, and d) in it, i need send to the server via POST method 3 of these fields (say a, b, and c) and the field d encrypted via md5.
I can't find the way to do this...
I can add an extra parameter (the encrypted d field, say e) but i don't want to send to the server the field d (because is not encrypted)... only the encrypted one...


myForm.on(
'beforeaction',
function(form, action) {

if (action.type == 'submit') {
Ext.apply(action.options.params || {}, {password: hex_md5(form.findField('password').getValue())});
}
}
);

or


if (myForm.isValid()) {
if (myForm.findField('password').getValue() == myForm.findField('repeated-password').getValue()) {
myForm.submit({
failure: envioDeInformacionNoExitosa,
params: {password: hex_md5(myForm.findField('password').getValue())},
success: ...
url: ...
});
} else {...}
}


If i add an extra parameter with the same field name in the submit method i have two parameters with this name d (without encryption) and d (with encryption)... and the server receives the field d without encryption...
Also i try to change the field value before do the submit and don't works
There is some way to access to the parameters that will be send to the server?
Anybody can help me with this problem?
Thanks

PD: I'm using the latest release of Ext...

wolverine4277
28 Jul 2007, 8:24 AM
Finally i got working, i'm not sure if the best choice but works... there is the solution:


myForm.on('beforeaction', function(form, action) {

if (action.type == 'submit') {
form.findField('password').disable();
action.options.params = action.options.params || {};
Ext.apply(action.options.params, {password: hex_md5(form.findField('password').getValue())});
});

(the disabled fields will not pass as parameters, that is the trick ;))


myForm.on('actioncomplete', function(form, action) {

if (action.type == 'submit') {
form.findField('password').enable();
}
});

if anybody knows another way to do this suggestions are welcome!

extjs_new
22 Feb 2009, 9:06 PM
Is there any new way for Ext 2.2 ?? I need this too.
How can I change the value of a certain textfield (password field to be encrypt) before submitting?

I tried this:


var form = login.getForm();

Ext.apply(login.form.baseParams,{loginPassword: Ext.util.MD5(password.getValue()) });

login.getForm().submit({
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
success:function(){
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){if (btn == 'ok'){
var redirect = 'loginsuccessful.php';
window.location = redirect;
}
});

But when submitting I have now two loginPassword that will be send to the server. One is encrypted and the other is not. How can I change the value of a certain textfield (password field to be encrypt) before submitting? And only the encrypted value should be send.