Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input with type=submit inside partial does not submit its own value #2566

Closed
Sleepful opened this issue Jul 2, 2024 · 3 comments
Closed
Labels
bug Something isn't working.

Comments

@Sleepful
Copy link

Sleepful commented Jul 2, 2024

consider:

      <form
        f-partial="/partial/car_type"
        method="post"
      />
            <input
              type="submit"
              class="hidden"
              name="car"
              value="a"/>

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.

@marvinhagemeister
Copy link
Collaborator

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?

@Sleepful
Copy link
Author

Sleepful commented Jul 2, 2024

@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 
@marvinhagemeister marvinhagemeister added the bug Something isn't working. label Jul 2, 2024
@marvinhagemeister
Copy link
Collaborator

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 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
2 participants