Closed nguyendkn closed 2 months ago
Thanks for contacting us @nguyendkn . We need to add the Name
property for the components. Would you please help us sending a PR for that?
我也一样的问题,而且当关闭预呈现时就不会报错 <Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
I have simillar issue. tried setting render mode as @stfei proposed, didn't work, can not add method="post" because:
[2024-01-03T07:30:42.129Z] Error: System.InvalidOperationException: Object of type 'AntDesign.Form`1[[ProjectName.LoginFormModel, ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' does not have a property matching the name 'method'.
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.ThrowForUnknownIncomingParameterName(Type targetType, String parameterName)
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target)
at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
full example:
<Form Model="@Model" Name="login" method="post" // method attribute throws error
OnFinish="OnFinish"
OnFinishFailed="OnFinishFailed"
LabelColSpan="8"
WrapperColSpan="16">
<FormItem Label="Username">
<Input @bind-Value="@context.Username" />
</FormItem>
<FormItem Label="Password">
<InputPassword @bind-Value="@context.Password" />
</FormItem>
<FormItem WrapperColOffset="8" WrapperColSpan="16">
<Checkbox @bind-Value="context.RememberMe">Remember me</Checkbox>
</FormItem>
<FormItem WrapperColOffset="8" WrapperColSpan="16">
<Button Type="@ButtonType.Primary" HtmlType="submit">
Submit
</Button>
</FormItem>
</Form>
@code
{
public class LoginFormModel
{
public string Username { get; set; }
public string Password { get; set; }
public bool RememberMe { get; set; }
}
[SupplyParameterFromForm]
private LoginFormModel Model { get; set; } = new LoginFormModel();
private void OnFinish(EditContext editContext)
{
Console.WriteLine($"Success:{JsonSerializer.Serialize(Model)}");
}
private void OnFinishFailed(EditContext editContext)
{
Console.WriteLine($"Failed:{JsonSerializer.Serialize(Model)}");
}
}
hi, is it fixed in the 0.17.2?I have simillar issue too.😂
Hello @HyokaChen , please use From at Interactive mode first. We will relese this feature in 0.18.0.
@nguyendkn We have add Method parameter in 0.18.0, but also have an issue #3709 , will be fixed in #3580 .
The POST request does not specify which form is being submitted. To fix this, ensure