paulkavan
16 Jul 2007, 4:28 PM
Sending a form with 'PUT' should send the body just like 'POST'.
Needed for ruby on rails code. PUT is used on /update requests and POST is used on the /create .
// Here's the code with the modifications.
Ext.form.Action.Submit.prototype.run = function(){
var o = this.options;
// old code
// var isPost = this.getMethod() == 'POST';
// new code
var isPostOrPut = (this.getMethod() == 'POST' || this.getMethod() == 'PUT');
if(o.clientValidation === false || this.form.isValid()){
Ext.lib.Ajax.formRequest(
this.form.el.dom,
this.getUrl(!isPostOrPut),
this.createCallback(),
// old code
// isPost ? this.getParams() : null, this.form.fileUpload, Ext.SSL_SECURE_URL);
// new code
isPostOrPut ? this.getParams() : null, this.form.fileUpload, Ext.SSL_SECURE_URL);
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
}
Needed for ruby on rails code. PUT is used on /update requests and POST is used on the /create .
// Here's the code with the modifications.
Ext.form.Action.Submit.prototype.run = function(){
var o = this.options;
// old code
// var isPost = this.getMethod() == 'POST';
// new code
var isPostOrPut = (this.getMethod() == 'POST' || this.getMethod() == 'PUT');
if(o.clientValidation === false || this.form.isValid()){
Ext.lib.Ajax.formRequest(
this.form.el.dom,
this.getUrl(!isPostOrPut),
this.createCallback(),
// old code
// isPost ? this.getParams() : null, this.form.fileUpload, Ext.SSL_SECURE_URL);
// new code
isPostOrPut ? this.getParams() : null, this.form.fileUpload, Ext.SSL_SECURE_URL);
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
}