mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
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>
37 lines
901 B
Vue
37 lines
901 B
Vue
<script setup lang="ts">
|
|
import type { FormError, FormSubmitEvent } from '#ui/types'
|
|
|
|
const state = reactive({
|
|
email: undefined,
|
|
password: undefined
|
|
})
|
|
|
|
const validate = (state: any): FormError[] => {
|
|
const errors = []
|
|
if (!state.email) errors.push({ path: 'email', message: 'Required' })
|
|
if (!state.password) errors.push({ path: 'password', message: 'Required' })
|
|
return errors
|
|
}
|
|
|
|
async function onSubmit (event: FormSubmitEvent<any>) {
|
|
// Do something with data
|
|
console.log(event.data)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UForm :validate="validate" :state="state" @submit="onSubmit">
|
|
<UFormGroup label="Email" name="email">
|
|
<UInput v-model="state.email" />
|
|
</UFormGroup>
|
|
|
|
<UFormGroup label="Password" name="password">
|
|
<UInput v-model="state.password" type="password" />
|
|
</UFormGroup>
|
|
|
|
<UButton type="submit">
|
|
Submit
|
|
</UButton>
|
|
</UForm>
|
|
</template>
|