title: MVC Radio Button Lists are not grouped when using the HtmlHelper class
body: <p>Having trouble creating a list of radio buttons that are grouped together, in MVC 3 specifically, but this also applies to MVC 2.</p>
  
  <p>The problem arises when radio buttons are generated using Html helpers and the model is part of an array.</p>
  
  <p>Here is the cut down version of my code.</p>
  
  <pre><code>public class CollectionOfStuff {
    public MVCModel[] Things { get; set }
  }
  
  /*This model is larger and represents a Person*/    
  public class MVCModel {
  
    [UIHint("Hidden")]
    public string Id { get; set; }
  
    public string Name { get; set; }
  
    public bool IsSelected { get; set; }
  }
  
  /*Assigned to new CollectionOfStuff property Things*/    
  var items = new[] { 
   new MVCModel() { Id="0" Name = "Name here" }, new MVCModel() { Id="1" Name = "Name there" } 
  }
  </code></pre>
  
  <p><strong>My parent view</strong></p>
  
  <pre><code>@model CollectionOfStuff
  
  @for (int i = 0; i &lt; Model.Things.Length; i++) {
      @Html.EditorFor(m =&gt; m.Things[i]);
  }
  </code></pre>
  
  <p><strong>My view rendering individual MVCModel objects</strong></p>
  
  <pre><code>@Model MVCModel
  
      @{
        var attr = new {
          Checked = Model.IsSelected ? "checked=checked" : ""
        };
      }
  
      @Html.RadioButtonFor(model =&gt; model, Model.Id, attr)
  </code></pre>
  
  <p>Produces this output:</p>
  
  <pre><code>&lt;input type="radio" value="0" name="MVCModel[0]" id="MVCModel_0_" data-val-required="You need to choose" data-val="true" /&gt;
  &lt;input type="radio" value="1" name="MVCModel[1]" id="MVCModel_1_" data-val-required="You need to choose" data-val="true" /&gt;
  </code></pre>
  
  <p>The radio buttons are not grouped, however it has the obvious advantage of writing out the meta data for validation.</p>
  
  <p>The other way is by calling:</p>
  
  <pre><code>@Html.RadioButton(name: "GroupName", value: Model.Id, isChecked: Model.IsSelected)     
  </code></pre>
  
  <p>Produces:</p>
  
  <pre><code>&lt;input type="radio" value="0" name="MVCModel[0].GroupName" id="MVCModel_0__GroupName"&gt;
  &lt;input type="radio" value="1" name="MVCModel[1].GroupName" id="MVCModel_1__GroupName"&gt;
  </code></pre>
  
  <p>Again, this doesn't produce the desired result. It's also missing the validation meta data.</p>
  
  <p>Another other option is creating a custom template, but the problem with this approach is that all the meta data required for validation is not present.</p>
  
  <p>Any ideas on how I can create grouped radio buttons or obtain meta data so I can create a template myself?</p>