diff --git a/src/fields/core/fieldSubmit.vue b/src/fields/core/fieldSubmit.vue index 346e983d..5d46b48a 100644 --- a/src/fields/core/fieldSubmit.vue +++ b/src/fields/core/fieldSubmit.vue @@ -12,10 +12,13 @@ methods: { onClick($event) { if (this.schema.validateBeforeSubmit === true) { + // prevent a
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); } @@ -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); } }