Closed DerekChasse closed 2 months ago
That wouldn't do a post request. It would simply call the function. Make sure you are not nested in another form
Then I'm confused as to BSForm's functionality then...
The form
element is specified as a post
... and I'm not nested within another form.
Are you using the new static server rendering? If not I'm confused about why it's doing a post instead of directly calling the function. But regardless should be able to just pass the @formname attribute like it's asking for.
Tested is indeed something for static and do see the issue fixing will post fix today
https://www.nuget.org/packages/BlazorStrap/5.2.102-Preview1
Adds support for static forms please bring in the V4 or V5 with the same version number
Example.
@page "/counter"
@using System.ComponentModel.DataAnnotations
<BSForm Model="Model" OnValidSubmit="Submit" FormName="Starship1">
<DataAnnotationsValidator />
<div>
<label>
Identifier:
<BSInput InputType="InputType.Text" @bind-Value="Model!.Id" />
<BSFeedback For="@(() => Model.Id)" ValidMessage="ID looks good." />
</label>
</div>
<div>
<BSButton IsSubmit="true" Color="BSColor.Primary">Submit</BSButton>
</div>
</BSForm>
@code {
[SupplyParameterFromForm]
public Starship? Model { get; set; }
protected override void OnInitialized()
{
Model ??= new();
}
private void Submit()
{
Console.WriteLine($"Model.Id: {Model!.Id}");
}
public class Starship
{
[Required(ErrorMessage = "ID must be provided.")]
public string? Id { get; set; }
}
}
Confirming the fix.
Thanks for the quick turnaround!
I've got a form that I'm having issues submitting with a relatively basic example...
I'm not seeing anything remarkably different from the various sample forms that I've seen referenced.
I'm using the latest version at time of writing. 5.2.100
The POST request does not specify which form is being submitted. To fix this, ensure <form> elements have a @formname attribute with any unique value, or pass a FormName parameter if using <EditForm>.
SignIn.razor
SignIn.razor.cs