The Blazor documentation's Form Validation example has a submit button component within the EditForm
component:
<EditForm Model="@starship" > OnValidSubmit="@HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <p> <label for="identifier">Identifier: </label> <InputText id="identifier" bind Value="@starship.Identifier" /> </p> Snip.... <button type="submit">Submit</button> Snip... </EditForm>
Is there anyway to place that submit button outside of the EditForm
tags and still have it 'natively' trigger the submit for that EditForm
component without resorting to using JavaScript?
i.e. for the code to look something like this:
<!-- Want this button to submit the form in the EditForm tags-->
<button type="submit">Submit</button>
Snip...
<EditForm Model="@starship" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label for="identifier">Identifier: </label>
<InputText id="identifier" bind-Value="@starship.Identifier" />
</p>
</EditForm>