feat(Form): handle @error event (#718)

Co-authored-by: Albert <albert@Alberts-MacBook-Pro.local>
Co-authored-by: Romain Hamel <romain@boilr.io>
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Albert
2023-10-10 11:47:22 -04:00
committed by GitHub
parent 1df07e2b4c
commit e16379fdbd
12 changed files with 142 additions and 69 deletions

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { z } from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui/dist/runtime/types'
import type { FormSubmitEvent } from '#ui/types'
const options = [
{ label: 'Option 1', value: 'option-1' },
@@ -45,19 +45,14 @@ type Schema = z.infer<typeof schema>
const form = ref()
async function submit (event: FormSubmitEvent<Schema>) {
async function onSubmit (event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data)
}
</script>
<template>
<UForm
ref="form"
:schema="schema"
:state="state"
@submit="submit"
>
<UForm ref="form" :schema="schema" :state="state" @submit="onSubmit">
<UFormGroup name="input" label="Input">
<UInput v-model="state.input" />
</UFormGroup>