How to read a complex view model on POST?
- by Interfector
Hello,
I have an user view model that has the following properties:
public User user;
public List<Language> Languages;
I send the above model to the view and use html helpers to build the form, so I end up with something like:
<form action="/Users/Edit/5" method="post"><input id="user_UserId" name="user.UserId" type="hidden" value="5" />
First Name
Last Name
Email
Language
-
en
en
Now, I try to read the POST in something that initially was something like :
[AcceptVerbs( HttpVerbs.Post )]
public ActionResult Edit( int UserId, FormCollection form ) {
and cannot get the user.UserId variable, user.FirstName variable etc.
Any idea what needs to be done to be able to read this kind of POST request. I'm kind of reluctant to modifying my ViewModel as it is very simple and easy to maintain as it is.
Thank you.