I have a BookCreateModel which consists of book\'s plane info such as Title, PublishYear & etc plus a collection of book Authors (complex type) :
public clas
I stumbled upon this when I was trying to find the solution for pretty much the same issue. My workaround was to kick the can down the road, ie. make wrapper model for the collection and use that in the editor template. In provided case, it would be:
public class BookCreateModel
{
public string Title { get; set; }
public int Year { get; set; }
public BookAuthorsModel Authors { get; set; }
}
public class BookAuthorsModel
{
IList Items { get; set; }
}
Then rename your editor template to "BookAuthorsModel.cshtml" and make it like this:
@model BookAuthorsModel
And when you want to use it, simply call:
@Html.EditorFor(m => m.Authors)
It should then generate input fields like so:
In my case I also changed Automapper mapping settings appropriately Controller code. This is not usable for some more complex scenarios however and is thus probably just a workaround.