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

[2.0.0-alpha2] Form submission issue with multipart/form-data. #2317

Closed
heikkilamarko opened this issue Feb 14, 2024 · 7 comments
Closed

[2.0.0-alpha2] Form submission issue with multipart/form-data. #2317

heikkilamarko opened this issue Feb 14, 2024 · 7 comments
Labels
2.0 bug Something isn't working

Comments

@heikkilamarko
Copy link

heikkilamarko commented Feb 14, 2024

I have the following form in my app, which includes text and file inputs:

<form
	id="task-new-form"
	enctype="multipart/form-data"
	autocomplete="off"
	hx-post="/ui/tasks"
	hx-target="#tasks-table"
	hx-swap="innerHTML"
>...</form>

This code worked flawlessly with htmx version 2.0.0-alpha1. However, after updating to htmx version 2.0.0-alpha2, the form submission stopped working. I suspect this issue is related to changes in how multipart/form-data is handled in htmx:

Screenshot 2024-02-14 at 21 08 55
@heikkilamarko heikkilamarko changed the title [2.0.0-alpha2] Form submission Issue with multipart/form-data. [2.0.0-alpha2] Form submission issue with multipart/form-data. Feb 14, 2024
@Telroshan Telroshan added bug Something isn't working 2.0 labels Feb 25, 2024
@heikkilamarko
Copy link
Author

Also reproducible in [2.0.0-beta2].

@Telroshan
Copy link
Collaborator

Hey, is the request not sent at all, or is it that it doesn't contain the expected payload (in which case, could you provide a screenshot of the generated payload) ? Do you have any error in console or does it fail silently ?

@heikkilamarko
Copy link
Author

heikkilamarko commented Apr 12, 2024

Screenshot for <script src="https://unpkg.com/htmx.org@1.9.11"></script>

Screenshot 2024-04-12 at 17 37 27

Screenshot for <script src="https://unpkg.com/htmx.org@2.0.0-beta2/dist/htmx.min.js"></script>

Screenshot 2024-04-12 at 17 41 04

@Telroshan
Copy link
Collaborator

Thanks, could you also show us the full content of the Headers tab, to be able to fully compare those 2 requests ?

@heikkilamarko
Copy link
Author

Headers for <script src="https://unpkg.com/htmx.org@1.9.11"></script>

Screenshot 2024-04-12 at 19 52 19

Headers for <script src="https://unpkg.com/htmx.org@2.0.0-beta2/dist/htmx.min.js"></script>

Screenshot 2024-04-12 at 19 54 43

Telroshan added a commit to Telroshan/htmx that referenced this issue Apr 14, 2024
Couldn't get the proxy object to work properly with XMLHTTPRequest's send method.
Even though calls are being forwarded to its underlying FormData through the proxy, the request won't set its type to multipart/form-data when appropriate and instead send a text/plain request
1cg pushed a commit that referenced this issue Apr 17, 2024
Couldn't get the proxy object to work properly with XMLHTTPRequest's send method.
Even though calls are being forwarded to its underlying FormData through the proxy, the request won't set its type to multipart/form-data when appropriate and instead send a text/plain request
@Telroshan
Copy link
Collaborator

Hey (for some reason I forgot to follow up here), could you try again with the latest beta version and let us know if the issue persists?

@heikkilamarko
Copy link
Author

I tried the latest beta. Everything works okay now. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants