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

Method of submit value propagation makes certain workflows impossible #117

Closed
lukearnould opened this issue Aug 6, 2024 · 3 comments · Fixed by #118
Closed

Method of submit value propagation makes certain workflows impossible #117

lukearnould opened this issue Aug 6, 2024 · 3 comments · Fixed by #118
Labels
bug Something isn't working

Comments

@lukearnould
Copy link

Consider a form like the following that POSTs to an endpoint that returns a FileContentResult:

<form asp-action="Download" asp-controller="Home">
    <button type="submit" name="format" value="PDF">Download PDF</button>
    <button type="submit" name="format" value="Excel">Download Excel</button>
</form>

When using this form with aspnet-client-validation, a hidden input gets created upon submit button click in order to POST the button's value. It seems this behavior was introduced here in order to work around limitations of .submit() in JavaScript: #52

The issue with this is that the hidden input does not get cleaned up after instantiation, and the page does not reload in this instance due to the nature of a FileContentResult endpoint. This causes conflicts when clicking a different submit button later as the hidden input will override its value due to possessing the same name attribute value ("format").

@haacked haacked added the bug Something isn't working label Aug 7, 2024
@haacked
Copy link
Owner

haacked commented Aug 7, 2024

Thanks for the error report! I have a PR with a fix. Just need a review.

@lukearnould
Copy link
Author

Thank you for the quick turnaround on this!

@haacked
Copy link
Owner

haacked commented Aug 8, 2024

Fix is now published to NPM

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

Successfully merging a pull request may close this issue.

2 participants