View Full Version : Ext.Direct form submit without formHandler

26 Aug 2009, 1:54 AM
Hey Team,

I would like to do an Ext.Direct form Post without "formHandler" set. I.e. I want the form to post JSON.

api: {
load: MyAPI.get,
submit: MyAPI.set
baseParams: {id: this.customerId},
paramsAsHash: true,

The get works perfectly. The set however, sends the following:


via firebug I see that posted is:


I can just do a form serialise and send the data. But I imagine there is an easier inbuilt way?


26 Aug 2009, 7:25 PM
Why do we ever need to set "formHandler" ? It appears that a form can only post data to Ext.Direct that is setup as a formHandler, and it appears that other request must not be a formHandler or they don't work at all (or at least do not fire when called).

Here is a simple example:

url: "/direct/cgi/simple/router.cgi",
actions: {
Profile: [
name: 'doTest',
len: 1,
formHandler: false
console.log("Calling doTest");
Profile.doTest('Scott', function(result, e) {
console.log("Returned result", result);

If you set formHandler: true - you do not get a request on the server, nor (obviously) a reply. If you set it to 'false' it all works as expected.

Now take the opposite, and use it in a form:

api: {
load: Profile.getBasicInfo,
submit: Profile.updateBasicInfo

then if you set formHandler: true in the api you get the correct form data posted as expected, but if you set it to false you get:


So there is one of two possibilities I can see.

I am not setting it up correctly to allow JSON instead of form data to be sent on a form.
OR it is unnecessary to setup the formHandler ever because it is implied and internally understood anyway.


10 Sep 2009, 12:16 AM
We end up doing something like that... (more or less... not sure if it will work because I had to cut/paste part of our class)

Ext.form.Action.TefDirectSubmit = Ext.extend(Ext.form.Action.DirectSubmit, {
run : function(){
var o = this.options;
if(o.clientValidation === false || this.form.isValid()){
// tag on any additional params to be posted in the
// form scope
this.success.params = this.getParams();
this.form.api.submit(this.form.getValues(), this.success, this);
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
Ext.form.Action.ACTION_TYPES['directsubmit'] = Ext.form.Action.TefDirectSubmit;

The idea is to send this.form.getValues(), not this.form.el.dom