[Vuejs]-Laravel Inertia vue form event triggered even on non-submit button

0👍

use the useForm instead

import { useForm } from '@inertiajs/vue3';

const form = useForm({
    email: null,
    password: null, 
    remember: null,
    loading: false
});

const submit = () => {
    form.loading = true
    form.transform(data => ({
        ...data,
        remember: form.remember ? 'on' : '',
    })).post(route('login'), {
        onFinish: () => { 
            form.loading = false
            form.reset('password')
        },
    });
};

route('login') put the route name here instead of the link

Leave a comment