title: CslaModelBinder not binding child list
body: <p>I have the following business classes</p>
  
  <pre><code>public class EditableRoot:Csla.BusinessBase&lt;EditableRoot&gt;
  {
      public string Name { get; private set; }
      public int Id { get; private set; }
  
      public static EditableRoot New() {
          return DataPortal.Create&lt;EditableRoot&gt;();
      }
  
      public static readonly PropertyInfo&lt;EditableChildList&gt; ChildListProperty = RegisterProperty&lt;EditableChildList&gt;(c =&gt; c.ChildList, RelationshipTypes.Child);
      public EditableChildList ChildList
      {
          get { return GetProperty(ChildListProperty); }
          private set { SetProperty(ChildListProperty, value); }
      }
      protected override void DataPortal_Create()
      {
          ChildList = EditableChildList.New();
      }
  
  }
  public class EditableChildList : Csla.BusinessListBase&lt;EditableChildList,EditableChild&gt;
  {
      public static EditableChildList New() { return DataPortal.CreateChild&lt;EditableChildList&gt;(); }
  }
  public class EditableChild : Csla.BusinessBase&lt;EditableChild&gt;
  {
      public static readonly PropertyInfo&lt;string&gt; AssignedByProperty = RegisterProperty&lt;string&gt;(c =&gt; c.AssignedBy);
      public string AssignedBy
      {
          get { return GetProperty(AssignedByProperty); }
          private set { LoadProperty(AssignedByProperty, value); }
      }
      public static readonly PropertyInfo&lt;int&gt; DocTypeIDProperty = RegisterProperty&lt;int&gt;(c =&gt; c.DocTypeID);
      public int DocTypeID
      {
          get { return GetProperty(DocTypeIDProperty); }
          set { SetProperty(DocTypeIDProperty, value); }
      }
      public static EditableChild New(int docTypeId) { return DataPortal.CreateChild&lt;EditableChild&gt;(docTypeId); }
      void Child_Create(int docTypeId)
      {
          DocTypeID = docTypeId;
          AssignedBy = "AssignedBy" + docTypeId;
      }
  
  }
  </code></pre>
  
  <p>And I have controller</p>
  
  <pre><code> public class ComplexTypeController : Csla.Web.Mvc.Controller, Csla.Web.Mvc.IModelCreator
  {
      //
      // GET: /ComplexType/
      public ActionResult Create()
      {
          EditableRoot type = EditableRoot.New();
          ViewData.Model = type;
          return View();
      }
  
      [HttpPost]
      public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit)
      {
          if (submit != "Create")
          {
              Random rand = new Random();
  
              complexType.ChildList.Add(EditableChild.New(rand.Next()));
  
          }
          ViewData.Model = complexType;
          return View();
      }
  
      public object CreateModel(Type modelType)
      {
          if (modelType == typeof(EditableRoot))
              return EditableRoot.New();
          else if (modelType == typeof(EditableChildList))
              return EditableChildList.New();
          else if (modelType == typeof(EditableChild))
              return EditableChild.New(0);
          else
              return Activator.CreateInstance(modelType);
      }
  }
  </code></pre>
  
  <p>And I have view</p>
  
  <pre><code> @model EditableRoot
  
   @{
       ViewBag.Title = "Create";
   }
  
   &lt;h2&gt;Create&lt;/h2&gt;
   @using (Html.BeginForm())
   {
       @Html.DisplayFor(m =&gt; m.Name);
       @Html.HiddenFor(m =&gt; m.Id);
       &lt;table&gt;
           &lt;thead&gt;
               &lt;tr&gt;
                   &lt;th&gt;Child Type Name&lt;/th&gt;
                   &lt;td&gt;Child Type Id&lt;/td&gt;
               &lt;/tr&gt;
           &lt;/thead&gt;
  
  
      &lt;tbody&gt;
              @for (int i = 0; i &lt; Model.ChildList.Count(); i++)
              {
                  &lt;tr&gt;
                      &lt;td&gt;
                          @Html.TextBoxFor(a =&gt; Model.ChildListIdea.AssignedBy)
                      &lt;/td&gt;
                      &lt;td&gt;
                          @Html.TextBoxFor(a =&gt; Model.ChildListIdea.DocTypeID)
                      &lt;/td&gt;
                  &lt;/tr&gt;
              }
          &lt;/tbody&gt;
      &lt;/table&gt;
     &lt;input name="submit" type="submit" id="submit" value="Create" /&gt;
      &lt;input name="submit" type="submit" id="process" value="Add Child" /&gt;                       
  }
  </code></pre>
  
  <p>When I add an EditableChild by clicking the "Add Child" button then click the "Create" button the ChildList property of the EditableRoot object in the public ActionResult Create(EditableRoot complexType, FormCollection collection, string submit) call is not bound.</p>
  
  <p>In other words the child list EditableRoot.ChildList is not bound, no items in the list, even though the html in the view follows the conventions for binding lists of complex types. And when I view the actual html in the browser the rows emitted for the items in EditableRoot.ChildList are present and correctly named.</p>
  
  <p>However, I got the CslaModelBinder from github and put it into my project and wired up the mvc default modelbinder to use it. Then I changed the CslaModelBinder method</p>
  
  <p>public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)</p>
  
  <p>to look like this</p>
  
  <pre><code>public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
              {
                  //if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                  //    return BindCslaCollection(controllerContext, bindingContext);
  
                  var suppress = bindingContext.Model as Csla.Core.ICheckRules;
                  if (suppress != null)
                      suppress.SuppressRuleChecking();
                  var result = base.BindModel(controllerContext, bindingContext);
                  return result;
              }
  </code></pre>
  
  <p>Everything worked. The EditableRoot.ChildList property is bound, the expected items are in the list.</p>
  
  <p>Ultimately my modification of the CslaModelBinder method</p>
  
  <p>public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)</p>
  
  <p>comments out the handling of binding Csla IEditableCollection and so the method ultimately calls the BindModel method on the base class, DefaultModelBinder. Which works.</p>
  
  <p>But, if I use my modified CslaModelBinder will I run into problems elsewhere?</p>
  
  <p>If DefaultModelBinder can handle binding of Csla.Core.IEditableCollection types then why</p>
  
  <p>if (typeof(Csla.Core.IEditableCollection).IsAssignableFrom((bindingContext.ModelType)))
                      return BindCslaCollection(controllerContext, bindingContext);</p>
  
  <p>???</p>