Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

Step2Form.vue

36 lines948 Bytes

1<script setup lang="ts">
2import { computed } from 'vue'
3import { step2Schema, stepValidator } from './shared-form.ts'
4import type { VueFormType } from '@tanstack/vue-form'
5import type { wizardFormOpts } from './shared-form.ts'
6​
7const props = defineProps<{
8 form: VueFormType<typeof wizardFormOpts>
9 step: number
10 setStep: (step: number) => void
11}>()
12​
13const form = computed(() => props.form)
14​
15function submitForm() {
16 void props.form.handleSubmit()
18</script>
19​
20<template>
21 <form.FormGroup
22 name="step2"
23 :validators="[stepValidator(step2Schema)]"
24 :on-submit="submitForm"
25 v-slot="{ group }"
26 >
27 <form @submit.prevent.stop="group.handleSubmit()">
28 <group.Field name="name" v-slot="{ field }">
29 <field.TextField label="Step 2 Name" />
30 </group.Field>
31​
32 <button type="button" @click="setStep(step - 1)">Back</button>
33 <form.SubscribeButton label="Submit" />
34 </form>
35 </form.FormGroup>
36</template>