Closed Sleepful closed 2 days ago
Is the input inside the form? In the snippet the <form />
tag is self closing or is that a copy & paste error here and the form encapsulates the input element in your app?
@marvinhagemeister copy & paste error, my bad. Here is a better copy/paste
<form
f-partial={`/load_version`}
method="post"
>
<input
type="submit"
name="version"
value="saved"
class="m-2 bg-blue-600"
/>
</form>
then in the route:
async POST(req, ctx) {
const form = await req.formData();
const formValues = Object.fromEntries(form.entries());
console.log({ formValues });
// prints empty object for formValues, if I remove partial navigation
// and use a standard `action` route, it does display the value though
Good news: Just took a look at this and it is already fixed in main
. I'm not sure which exact commit resolved it, but I cannot reproduce it there anymore 🎉
consider:
when this input is clicked and the form is submitted, the
req.formData();
should contain the value{ car: "a"}
, but it does not. It is empty instead.