Skip to content

Commit

Permalink
move beginSubmit hook call to before prevalidation (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Mar 25, 2015
1 parent 44e8cc4 commit 2f01f73
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions autoform-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ Template.autoForm.events({
endSubmission();
}

// Run beginSubmit hooks (disable submit button or form, etc.)
// NOTE: This needs to stay after getFormValues in case a
// beginSubmit hook disables inputs. We don't get values for
// disabled inputs, but if they are just disabling during submission,
// then we actually do want the values.
//
// Also keep this before prevalidation so that sticky errors can be
// removed in this hook.
beginSubmit(formId, template, hookContext);

// Ask form type definition whether we should prevalidate. By default we do.
var shouldPrevalidate = ftd.shouldPrevalidate ? ftd.shouldPrevalidate.call(hookContext) : true;

Expand All @@ -296,13 +306,6 @@ Template.autoForm.events({
}
}

// Run beginSubmit hooks (disable submit button or form, etc.)
// NOTE: This needs to stay after getFormValues in case a
// beginSubmit hook disables inputs. We don't get values for
// disabled inputs, but if they are just disabling during submission,
// then we actually do want the values.
beginSubmit(formId, template, hookContext);

// Call onSubmit from the form type definition
ftd.onSubmit.call(_.extend({
runBeforeHooks: runBeforeHooks,
Expand Down

0 comments on commit 2f01f73

Please sign in to comment.