ExtApp.form = {
  submit: function(config) {
    var form = Ext.getCmp(config.form);
    Ext.applyIf(config, {
      method: 'POST',
      scope: window,
      waitMsg: 'Saving Form',
      waitTitle: 'Please Wait...',
      params: {},
      success: ExtApp.form.success,
      failure: ExtApp.form.failure
    });

    form.getForm().submit(config);
  },
  success: function(form, action) {
    if (action.result.success) {
      if (this.close) { this.close(); }
      if (this.onSuccess) { this.onSuccess.call(this, form, action, action.result); }
      if (form.onSave) { form.onSave.call(form, form, action, action.result); }
    }
    if (action.options.onSave) {
      action.options.onSave.call(action.options.scope || this, form, action, action.result);
    }
    if (action.result.flash) {
      ExtApp.Notice.show({ msg: action.result.flash });
    }
  },
  failure: function(form, action) {
    if (action.result && action.result.flash) {
      ExtApp.Notice.show({ msg: action.result.flash });
    }
  }
};