I need to build a fully dynamic form.
At the moment I am rendering a component based on information returned from an API.
The item.QuestionType is an input component I have built e.g., "Textbox"
@foreach (var item in Model)
{
Type qType = Type.GetType($"DynamicComponents.Pages.{item.QuestionType}");
<DynamicComponent Type="@qType"></DynamicComponent>
}
Textbox.razor component:
<h3>TextBox</h3>
<input type="text" />
I have researched online and there is nothing about adding Validation to these components. I would like to add a validation attribute (e.g. [Required]) to each component and hook it up with an EditContext but I don't think that can work.