title: Dropdown as a custom editor for object list
body: <p>I have a view that displays all the object's properties by using <code>ModelMetadata</code>:</p>
  
  <pre><code>  @foreach (var property in ViewData.ModelMetadata.Properties)
      {
          &lt;div class="form-group"&gt;
              @Html.Label(property.PropertyName, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.Editor(property.PropertyName, new { htmlAttributes = new { @class = "form-control" }, Context = context })
                  @Html.ValidationMessage(property.PropertyName, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
      }
  </code></pre>
  
  <p>But my Model has the next property:</p>
  
  <pre><code>[Required]
  public virtual User Owner { get; set; }
  </code></pre>
  
  <p>It is supposed to show a dropdown with the list of users so I could select one.
  I have added the following editor template at <code>Views\Shared\EditorTemplates\User.cshtml</code>:</p>
  
  <pre><code>@using Views.Projects
  @model Models.Users.User
  @{
      Layout = null;
      var context = (ProjectContext) ViewData["Context"];
      var elements = new SelectList(context.AvailableUsers, Model);
  }
  
  @Html.DropDownListFor(x =&gt; x, elements)
  </code></pre>
  
  <p>But the changes doesn't seem to apply - whatever user I select is not saved in the object and validation fails (because the Owner == null, and it is required)</p>
  
  <p>How do I make this work?</p>
  
  <p><em>Update</em></p>
  
  <p>Raw html generated:</p>
  
  <pre><code>&lt;div class="form-group"&gt; 
      &lt;label class="control-label col-md-2" for="Owner"&gt;Owner&lt;/label&gt; 
      &lt;div class="col-md-10"&gt; 
          &lt;select id="Owner" name="Owner"&gt;
              &lt;option&gt;User1&lt;/option&gt; 
              &lt;option&gt;User2&lt;/option&gt;  
              &lt;option&gt;User3&lt;/option&gt;     
          &lt;/select&gt; 
       &lt;span class="field-validation-valid text-danger" data-valmsg-for="Owner" data-valmsg-replace="true"&gt;&lt;/span&gt; 
       &lt;/div&gt; 
  &lt;/div&gt;
  </code></pre>