PDA

View Full Version : [FIXED-627] BasicForm doesn't check clientValidation when using standardSubmit



dolittle
23 Feb 2010, 3:02 PM
I'm using Ext3.1.1

Ext.form.Action.Submit doesn't perform validation if the config option clientValidation is set to false but when using standardSubmit this option isn't checked

A fix:


submit : function(options){
if(this.standardSubmit){
var v;
if(options.clientValidation === false) {
v = true;
} else {
v = this.isValid();
}
if(v){
var el = this.el.dom;
if(this.url && Ext.isEmpty(el.action)){
el.action = this.url;
}
el.submit();
}
return v;
}
var submitAction = String.format('{0}submit', this.api ? 'direct' : '');
this.doAction(submitAction, options);
return this;
}

Thanks

mystix
24 Feb 2010, 11:29 AM
i'm a big fan of short code:


var v = options.clientValidation === false || this.isValid();

Jamie Avins
24 Feb 2010, 11:34 AM
I'm a bigger fan of readability. Let the compressor flatten the code...

mystix
24 Feb 2010, 11:38 AM
hmm... but if you translate the shortened code to simple english it makes complete sense (to me at least):

"if option.clientValidation is false, or this is valid, then v is true".

in fact i find it more confusing to set v = true when clientValidation is false.


just my 2 cents. :)

Jamie Avins
24 Feb 2010, 11:46 AM
This isn't a good example since it isn't very complex. These can get real ugly, real fast.

mystix
24 Feb 2010, 11:48 AM
agreed. for more complex cases, i'd vote for readability + maintainability.

Jamie Avins
9 Mar 2010, 3:14 PM
[type]: change
[module]: BasicForm
[id]: #627
[desc]: Fixes #627. standardSubmit now honors the clientValidation option (false now bypasses the isValid() check).

mdissel
13 Mar 2010, 3:22 AM
according to the documentation, the variable options is not required.. so when using the

frm.standardSubmit = true;
frm.getForm().submit();

you get an undefined error on the var options inside the basicform.submit() function

Jamie Avins
15 Mar 2010, 8:16 AM
Options now defaults to an empty object if none is supplied.