billbogaiv / hybrid-model-binding

Provides the ability to bind models using both ModelBinder and ValueProvider in ASP.NET Core.
MIT License
104 stars 19 forks source link

Nested Model not binding data in FromFrom request #19

Open VinhTue opened 5 years ago

artyom-p commented 4 years ago

Same for me.

image

Items are always null

drgrieve commented 4 years ago

Same issue. Resolved by adding FromForm to the property to use default model binding,

public ActionResult AdminAdd(CompanyDetailViewModel model)

public class CompanyDetailViewModel : CompanyViewModel
{
    public InviteEditModel Admin { get; set; }
}

Form data posted Id: 1 Admin.Email: jim@jim.com Admin.FirstName: 1 Admin.LastName: 2

Admin model is null.

Workaround: public ActionResult AdminAdd([FromForm]CompanyDetailViewModel model)