Repository navigation
Conversation
Author
|
@dotnet-policy-service agree |
3 tasks
JayArrowz
marked this pull request as ready for review
July 2, 2026 18:17
Contributor
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add EditForm.SubmitAsync for programmatic form submission
Description
Currently there is no way to submit an EditForm programmatically from C# code, because HandleSubmitAsync is private. This forces developers to manually call EditContext.Validate() and then invoke their submit handler separately, which breaks the form's submission flow and bypasses any client-side validation prompts.
This PR adds a public SubmitAsync method to EditForm that submits the form from code, triggering the same validation and submission lifecycle as if the user had clicked a submit button.
As suggested by @SteveSandersonMS #48613 (comment), this works by making a JS interop call to instruct the browser to submit the form via HTMLFormElement.requestSubmit(). This ensures that any expected client-side behaviors, such as triggering HTML's built-in validation prompts, also occur.
Interactive rendering: The resulting submit event is handled by the form's onsubmit handler, which runs the EditContext validation and invokes the appropriate OnSubmit, OnValidSubmit, or OnInvalidSubmit callback.
Server-side rendering (SSR): Not applicable. SubmitAsync relies on JS interop, which requires an interactive rendering mode. In pure SSR scenarios there is no JS interop available to call this method, use a regular instead.
Usage:
Fixes #48613