After trying with a more sophisticated viewmodel with no success I came to use a viewmodel which is like this:
public class CarteExpressViewModel
{
public string[] LesEntrees;
public string[] LesPlats;
public CarteExpressViewModel()
{
LesEntrees = new string[]{ "", "", "", "", "", "" };
LesPlats = new string[]{ "", "", "", "", "", "" };
}
}
I pass the viewModel in my create method of my controller
public ActionResult Create()
{
CarteExpressViewModel carteExpressViewModel = new CarteExpressViewModel();
return View(carteExpressViewModel);
}
Problem is I can see the input value if I use a FormCollection as parameter of my Post create method but everything is null if i use the viewmodel
My view is line this:
@for (int i = 0; i < Model.LesEntrees.Length; i++)
{
<div class="editor-label ">
@Html.LabelFor(model => model.LesEntrees[i], "Entrée n°" + (i + 1).ToString(), new { @class = " express_input_label" })
</div>
<div class="editor-field ">
@Html.EditorFor(model => model.LesEntrees[i], new { @class = " express-input" })
</div>
}
I can't see what's wrong but sure something should.