I have the following nested viewmodel class...
public class CustomerModel
{
public string name;
public Address mailingAddress;
public Address billingAddress;
}
public class Address
{
public string line1;
public string city;
public string country;
}
I was hoping that there is some automated way to create an edit page, but everything that I've tried and read indicates that the framework and code-generates only handle top level properties in your viewmodel. The 'name' property is the only one generated in the view and in the action, it is only the 'name' property that is populated with the addresses being left as null.
[HttpPost]
public ActionResult Edit(CustomerModel model)
however, if i manually add input boxes for the address (through partial views) and switch over to the FormCollection signature for the action, i get the appropriate address values entered on the screen.
is there any easy solution for this other than creating my own function to convert from FormCollection to CustomerModel?