46 lines
1.4 KiB
Vue
46 lines
1.4 KiB
Vue
<template>
|
|
<DocPTViewer :docs="docs">
|
|
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full sm:w-56">
|
|
<div class="flex flex-col gap-2">
|
|
<InputText name="username" type="text" placeholder="Username" fluid />
|
|
<Message v-if="$form.username?.invalid" severity="error">{{ $form.username.errors[0]?.message }}</Message>
|
|
</div>
|
|
<Button type="submit" severity="secondary" label="Submit" />
|
|
</Form>
|
|
</DocPTViewer>
|
|
</template>
|
|
|
|
<script>
|
|
import { getPTOptions } from '@/components/doc/helpers';
|
|
import { zodResolver } from '@primevue/form/resolvers';
|
|
import { z } from 'zod';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
docs: [
|
|
{
|
|
data: getPTOptions('Form'),
|
|
key: 'Form'
|
|
}
|
|
],
|
|
initialValues: {
|
|
username: ''
|
|
},
|
|
resolver: zodResolver(
|
|
z.object({
|
|
username: z.string().min(1, { message: 'Username is required.' })
|
|
})
|
|
)
|
|
};
|
|
},
|
|
methods: {
|
|
onFormSubmit({ valid }) {
|
|
if (valid) {
|
|
this.$toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 });
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|