View Full Version : Manipulating Ext.form data before submit
devnull
5 Jul 2007, 2:58 PM
Is there any way to manipulate the form field contents of an Ext.form before it is submitted (using form.submit)?
I have a login dialog that is dynamically created, but i would like to perform a simple hash on the values before they are submitted (low security model, keep honest people honest). It is also submitting the data in duplicate for some reason.
ex i have textfield "a" that i input "123" and textfield "b" that i input "456".
the server gets:
a=123
b=456
123=123
456=456
any ideas?
I am not terribly concerned about security here as this is an app that is only used on a corporate intranet, but i just dont feel right about passing passwords in the clear :)
i'm no expert, but this site may help
http://pajhome.org.uk/crypt/md5
Animal
5 Jul 2007, 11:28 PM
Use a handler on this event: http://extjs.com/deploy/ext-1.1-beta2/docs/output/Ext.form.BasicForm.html#event-beforeaction
devnull
6 Jul 2007, 9:07 AM
Well it does help knowing the correct event to use, but I am no closer to knowing how to modify the form contents. I had firebug fire up a debugger in the beforeaction event, and have been digging around looking for the right object to work on, but I can't seem to figure out how to get to the form fields, or figure out how Ext creates the key=value pairs.
I was thinking it would be nice to utilize all the nice things that come with a form.submit, but it looks like I will just have to create my own form handlers. The value=value pairs in the data are a big show-stopper in and of themselves, I don't want nor have I told it to make these.
tryanDLS
6 Jul 2007, 9:28 AM
1) Form has a findField method.
2) Look at the Action class to see what it does for a submit - that code is pretty easy to follow.
devnull
6 Jul 2007, 11:13 AM
Ok, the value=value pairs were just a bug in my debugging code (hah!) on the php side, i am getting correct information.
Turns out the solution thus far is to modify the form field contents using getValue and setValue, storing the plaintext contents so they can be restored if the server returns an error. It means the user sees the hash values in the form for a bit, but isnt a big deal to me.
mfw24
12 Jul 2007, 12:09 PM
are you building the hash values within the js? If so, would you mind sharing with us what that code looks like? (is it based off md5 or some other widely accepted method?)
thank you!
devnull
12 Jul 2007, 1:49 PM
pretty simple really, all i am doing is running it through a base64 encoding. Found a js script out there somewhere that has encode and decode functions, and of course php has them native.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.