PDA

View Full Version : Submit failure override



dizor
29 Sep 2010, 2:14 PM
How i can override standard form submit function?
I want have one failure handling funciton.



this.form.getForm().submit({
url: 'test',
success: function () {

}
});

Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {
failure: function () {
}
});


... doesn't work.

laurentParis
29 Sep 2010, 8:54 PM
witch kind error can handler your failure submit method ?

dizor
29 Sep 2010, 11:24 PM
I want have one default "failure" for all "submit".

laurentParis
30 Sep 2010, 12:17 AM
For me if I need to know if my form is on defaut before submit, I use myForm.isValid() and intercept failure after submit is mangaged by ajax component... I don't understand what do you need exactly, sorry !

dizor
30 Sep 2010, 2:53 AM
I want override standard failure function - so i do not have to enter it every time.

laurentParis
30 Sep 2010, 5:05 AM
ok... so try this



Ext.override(Ext.form.BasicForm, {
initComponent: function () {
Ext.form.BasicForm.superclass.initComponent.call(this);
this.on('actionfailed', function (action) {
// make what you need
}, this);
},


ps: they are not failure function for Submit action, failure are manage on succes method... failure is about http failure

look source code


// private
success : function(response){
var result = this.processResponse(response);
if(result === true || result.success){
this.form.afterAction(this, true);
return;
}
if(result.errors){
this.form.markInvalid(result.errors);
}
this.failureType = Ext.form.Action.SERVER_INVALID;
this.form.afterAction(this, false);
},