PDA

View Full Version : standardSubmit=true prevents beforesubmit handler from stopping form submission



wemakeitwork
28 Jul 2011, 11:18 PM
Sencha Touch version tested:

1.1.0


Platform tested against:

iOS 4


Steps to reproduce the problem:

have a FormPanel with standardSubmit=true and a beforesubmit handler that returns false


The result that was expected:

form submission isn't executed if beforesubmit returns false, as explained in the docs: "A return value of false from this listener will abort the submission attempt (regardless of standardSubmit configuration)"


The result that occurs instead:

form is submitted even if beforesubmit handler returns false


This looks suspicious in Ext.form.FormPanel:


// @private
onSubmit : function(e, t) {
if (!this.standardSubmit || this.fireEvent('beforesubmit', this, this.getValues(true)) === false) {
if (e) {
e.stopEvent();
}
}
}

if standardSubmit is true, then !standardSubmit is false. The if condition always evaluates to false (regardless of the result of beforesubmit), and the event never is stopped.