I am trying to build a form from a Json object, this Json object have a list of field object, each field object have a type (text, select, checkbox...) and validation object, the final result I want when submitting is a dictionary with a key of the field id and it's value , so I created for a partial view and a view model for every field type and in the index page I loop through the fields list and do a switch on the field type like this:
@foreach (var field in billerInvoiceFieldModels)
{
switch (field.Type.Tag)
{
case "TEXT":
@await Html.PartialAsync("Partials/_PartialTextField", new TextField
{
Key = field.Id.ToString(),
Name = field.Name,
Value = "",
IsRequired = true,
})
break;
...
}
}
The validation I added for every partial view model doesn't seem to work and I don't get the desired dictionary when submitting the form, note that I don't want to use JQuery or Ajax.
