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.36k stars 428 forks source link

Form helper ignores forceFormData (upgrading to inertiajs 1.0.0) #1412

Closed dr3tt closed 1 year ago

dr3tt commented 1 year ago

Version:

Describe the problem:

Upgraded to inertiajs 1.0.0. Before upgrade I was using forceFormData = true option to submit my forms (with POST methods):

form.post(url, {
  forceFormData: true,
});

To make them work now I need to add the following header option:

form.post(url, {
  forceFormData: true,
  headers: { "Content-Type": "multipart/form-data" },
});

Maybe is the new form helper ignoring forceFormData option?

devstack-be commented 1 year ago

What's your form content? Do you add "_method: 'PUT'"?

dr3tt commented 1 year ago

What's your form content? Do you add "_method: 'PUT'"?

I use the form helper:

const form = useForm({
  email: null,
  name: null,
});

On the backend, I'm using Django.

devstack-be commented 1 year ago

Try to use a route with PUT method on your backend and edit your useForm by the following:

const form = useForm({
_method: 'PUT',
  email: null,
  name: null,
});

form.post('...')
reinink commented 1 year ago

Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion.

In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.

Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it.

Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️