Lets say I have a partial view that contains both a checkbox and a numerical value. I have a ViewModel that contains a Model -- Terms -- that implements the partial view. When I submit it, the modifications made in the Terms Partial View does not reflect to the Terms property of ViewModel. I'm probably misunderstanding a concept or another on how it works, anyone care to point it out please?
View
@model ViewModel
@using (Html.BeginForm("ViewAction", "ViewController", FormMethod.Post))
{
// Other ViewModel Property Editors
@Html.Partial("Terms", Model.Terms)
<input type="submit" value="Submit" />
}
Partial View
@model Terms
@Html.CheckBoxFor(m => m.IsAccepted)
@Html.EditorFor(m => m.NumericalValue)
Controller
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult ViewAction(int id)
{
ViewModel vm = GetVmValues();
return View(vm);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ViewAction(ViewModel vm)
{
// Access ViewModel properties
}