I have a peculiar situation in which referencing 'model in my editor template produces a malformed index 'name' field:
Editor
@model IList<BillingRateItem>
@for (int i = 0;i < this.Model.Count(); i++)
{
@Html.HiddenFor(m => this.Model[i].BillingRateItemID)
}
The hidden field produced includes a period before the index, which is problematic:
HTML Rendered
<input id="Model_BillingRateItems__0__BillingRateItemID" name="Model.BillingRateItems.[0].BillingRateItemID" type="hidden" value="9">
What I want Rendered
Note that 'Model.BillingRateItems[0]' has no period between the name and the index. This is good!
<input id="Model_BillingRateItems__0__BillingRateItemID" name="Model.BillingRateItems[0].BillingRateItemID" type="hidden" value="9">
EDIT - This is an example of the view calling the editor
@model BillingRateViewModel // has multiple BillingRateItems
@Html.EditorFor(m=>m.BillingRateItems,"BillingRateItemsGrid")
Note: When I change the Editor to accept the parent object (e.g. BillingRate) the indexing works fine. Maybe the conclusion is simply the all editors will begin with a '.' regardless of the context. In the case of Enumerables it will add the '.[].' even though this does the native model binder no help in reconstructing the object.