Skip to content

closes #434, #408 - added $event to onValidationError #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/fields/core/fieldSubmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
methods: {
onClick($event) {
if (this.schema.validateBeforeSubmit === true) {
// prevent a <form /> from having it's submit event triggered
// when we have to validate data first
$event.preventDefault();
let errors = this.$parent.validate();
let handleErrors = (errors) => {
if(!isEmpty(errors) && isFunction(this.schema.onValidationError)) {
this.schema.onValidationError(this.model, this.schema, errors);
this.schema.onValidationError(this.model, this.schema, errors, $event);
} else if (isFunction(this.schema.onSubmit)) {
this.schema.onSubmit(this.model, this.schema, $event);
}
Expand All @@ -27,6 +30,8 @@
handleErrors(errors);
}
} else if (isFunction(this.schema.onSubmit)) {
// if we aren't validating, just pass the onSubmit handler the $event
// so it can be handled there
this.schema.onSubmit(this.model, this.schema, $event);
}
}
Expand Down