inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.02k stars 405 forks source link

ability to setData using array/objects on useForm #1911

Closed ph-hitachi closed 2 days ago

ph-hitachi commented 4 days ago

Hi

Describe the problem:

i want to use useForm but i can handle setData when passing js arrays as formData

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

const { data, setData, post, processing, errors, reset } = useForm({
        email: '',
        password: '',
    });

    // useEffect(() => {
    //     return () => {
    //         reset('password');
    //     };
    // }, []);

    const login = (formData: {email: string, password: string}) => {
        console.log(formData) // {email: 'example@mail.com', password: 'password'}
        post(route('login'), { 
            data: formData,
        });
    };
driesvints commented 2 days ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!