-
Notifications
You must be signed in to change notification settings - Fork 24
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
Validation breaks the formaction attribute #39
Comments
What is the behavior you observed and what is the behavior you expect? |
I was not able to reproduce this. I added a demo page for formaction here: #84 Here's the razor code: @page
@model DemoWeb.Pages.Demos.FormAction
@{
Layout = "Shared/_Layout";
}
<partial name="Shared/_StatusMessage" model="Model.StatusMessage"/>
<form method="post">
<input type="submit" value="Submit" asp-page-handler="Submit" />
<input type="submit" value="Save" asp-page-handler="Save"/>
</form> Here's the code behind: using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace DemoWeb.Pages.Demos;
public class FormAction : PageModel
{
[TempData]
public string? StatusMessage { get; set; }
public IActionResult OnPostSubmitAsync()
{
StatusMessage = "Submit button clicked";
return RedirectToPage();
}
public IActionResult OnPostSave()
{
StatusMessage = "Save button clicked";
return RedirectToPage();
}
} And it works fine as the screenshots show. |
@haacked I have been running into this issue and can reproduce it. It seems you have to have some form fields in addition to the buttons on the form to trigger the issue. I have been having some trouble getting the source to build locally and cannot get a proper pull request together right now, but if you make some minor modifications to the FormAction page mentioned above you should be able to reproduce the problem. FormAction.cshtml.cs becomes:
FormAction.cshtml becomes:
Hope this helps. |
What issues? Mind filing another issue for that? |
That helped a lot! I can confirm the issue. |
The problems I had were around getting NPM to behave on my machine, so I don't think it is an issue specifically with this project. I had planned on trying to work through it to sort the problem out but I keep getting sidetracked. Will definitely file an issue if I find something and think it is helpful though. |
Suppose there is the following form:
When using aspnet-client-validation, the form does not take into account the
formaction
attribute and the key/value passed to submit (if it was clicked). The only working solution is to addformnovalidate
attribute to buttons.The text was updated successfully, but these errors were encountered: