Skip to content

Handle submission

To handle form submissions, use the handleSubmit method. This method takes a callback function that provides the form data with autocompletion.

vue
<script setup lang="ts">
import { useForm } from 'vue-formify';

type LoginForm = {
	username: string;
	password: string;
}

const { Form, Field, handleSubmit } = useForm<LoginForm>(); 

const submit = handleSubmit((data) => {
	console.log(data)
});

</script>
<template>
	<Form @submit="submit">
		<Field name="username" />
		<Field name="password" type="password" />
		<button>Submit</button>
	</Form>
</template>