I have a view that works like a form so it loads a bunch of drop down and select from a FormViewModel class that is return from the Controllers in the ActionResult Index
. Once all the data is enter into the form I use the Html.BeginForm("Create"
to call the save method. The ActionResult Create(RequestForm model)
. So the question is I wanted to use two models, one to load and one to save the data. What I am doing now is have the object in from the FormViewModel and the RequestForm model.
Is there a better way to do this?
View:
@model FormViewModel
@using (Html.BeginForm("Create", "RequestForm", FormMethod.Post))
{
@Html.ValidationSummary(true);
<div class="k-content">
<h4>* Country</h4>
@Html.TextBoxFor(x => x.CountryId, new { id = "ddlCountry", @class = "form-control" })
@Html.ValidationMessageFor(model => model.CountryId)
</div>
}
FormViewModel
[Required]
public int? CountryId { get; set; }
public List<CountryModel> ListOfCountries { get; set; }
RequestForm Model
public class RequestForm
{
[Required]
public int? CountryId { get; set; }
}
Controllers
public ActionResult Create(RequestForm model)
{
var FormInfo = FormCreate(model);
return View("");
}