Closed nguyenvanbien95 closed 2 years ago
@nguyenvanbien95 Thanks for contacting us.
What is that you are trying to accomplish that doesn't work the way you expect?
a) <ValidationSummary Model="value" />
gets you some of the way, but the correct way to fix this would be to add the ability to specify a FieldIdentifier
onValidationMessage
:
<ValidationMessage Field="EditContext.Field(property.Name)" TValue="object" />
The unfortunate part here is that TValue
needs to be specified and has to be compile time expression for the generated code to correctly instantiate ValidationMessage<TValue>
. However, since it's only ever used to constrain the For
expression, and has no practical use in the component outside of it, using object
works fairly well.
b) We'd also need for a way for a FieldIdentifier
to be assigned to InputBase
. The FieldIdentifier
calculated using ValueExpression
is used to construct the FieldIdentifier
for field validation - https://github.com/aspnet/AspNetCore/blob/master/src/Components/Web/src/Forms/InputBase.cs#L203.
This is just my temporary solution. I hope there is a better way to implement it in code base. Thank you for your detail explaining.
Hi. Thanks for contacting us. We're closing this issue as there was not much community interest in this ask for quite a while now. You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.
Thank you for your effors to build awesome Blazor. I want to create dynamic form using Reflection for TValue: Value as:
In MVC, i found a way for that Here.
I think ValidationMessage can support PropertyInfo
<ValidationMessage Model="@Value" NameField="p.Name"></ValidationMessage>