I would extend Ext.form.Basic
like this:
Ext.define('MyApp.form.Basic',{
extend:'Ext.form.Basic',
isValid: function() {
var me = this,
invalid;
Ext.suspendLayouts();
invalid = me.getFields().filterBy(function(field) {
return !field.validate() && !field.mayBeInvalid;
});
Ext.resumeLayouts(true);
return invalid.length < 1;
}
});
Ext.define('MyApp.form.Panel',{
extend:'Ext.form.Panel',
xtype:'myformpanel',
createForm: function() {
var cfg = {},
props = this.basicFormConfigs,
len = props.length,
i = 0,
prop;
for (; i < len; ++i) {
prop = props[i];
cfg[prop] = this[prop];
}
return new MyApp.form.Basic(this, cfg);
}
});
so you can annotate the fields like this:
xtype:'myformpanel',
items:[{
xtype:'textfield',
// this field should be validated.
},{
xtype:'textfield',
mayBeInvalid:true // our own extension property
// this field should not block the form submission
}]
and then you submit as usual.
Completely untested, but you'll do that for me, I guess :)
The alternative, if you really only need it in a single form with a single submit()
call, is to do the same thing manually before submission:
var invalidFields = formpanel.getForm().getFields().filterBy(function(field) {
return !field.validate() && !field.mayBeInvalid;
});
if(invalidFields.length < 1) form.submit({
clientValidation: false, // do not validate anymore
...
})