How can I have multiple inputs in a page all feed into a list of my model where the model is defined as
public class MatrixSet
{
List<MatrixPoints> matrixPoints { get; set; }
}
public class MatrixPoints
{
double x { get; set; }
double y { get; set; }
}
I am not sure what to use in the view to have say, 4 input fields which all input matrix points and then when posted the controller will have the model of type matrixset which will contain a list of the matrix points entered in the view. I know how to do this without passing the model but I am trying to adhere to best practice methods. Can I just have each input field be @Html.TextBoxFor() and then it will just fill a list of MatrixPoints in MatrixSet assuming that at the top of my view I am using @model Models.MatrixSet?
Found the answer:
In this regard you can add items to your model objects iteratively and dynamically while still holding the entire model when the form is posted and retaining the validation from the defined model.