View Full Version : Change form value on submit

23 Apr 2013, 9:21 AM
I want to BASE64 encode all values sent by a form in an invisible way.
I have a submit button attached to the form which calls form.getValues(); and then does a submit(); call which has callbacks for success and failure which both change them back to normal by calling setValues().
This works but for the time the AJAX request takes the form elements display the BASE64 encoded value, this is ugly.

I am pretty stuck on this.

I tried to do it through the params config of the submit but this is only a setter for undefined keys and I want to alter them, it does nothing with existing keys.

Also the beforeaction handler did not allow me to do it.

And I tried some others from the docs which had zero success.

I did find this forum post:

It puts like this handler on the form:
listeners: {
beforesubmit: function(form, values, options) {
values.test = "hello";

It is what I want but I can't find that listener in the docs and when I attach it to my form it won't call when I submit it which I would expect to be the moment that it would do something.

24 Apr 2013, 8:21 PM
You might override the getSubmitValue() method for the fields you're encoding.

Or, you can have a hidden field that has the encoded value and you set it on the change event of the convenience field used for input by the user.