feat(Form): expose submit function (#1186)

This commit is contained in:
Romain Hamel
2024-01-02 16:28:38 +01:00
committed by GitHub
parent d64cb8a6fd
commit 4a25a12390
3 changed files with 8 additions and 1 deletions

View File

@@ -144,6 +144,9 @@ export default defineComponent({
errors.value = errs
}
},
async submit () {
await onSubmit(new Event('submit'))
},
getErrors (path?: string) {
if (path) {
return errors.value.filter((err) => err.path === path)

View File

@@ -15,6 +15,7 @@ export interface Form<T> {
errors: Ref<FormError[]>
setErrors(errs: FormError[], path?: string): void
getErrors(path?: string): FormError[]
submit(): Promise<void>
}
export type FormSubmitEvent<T> = SubmitEvent & { data: T }