title: HTML Form: POST an array of objects
body: <p>Submitting a class roster.  Adding 3 students at once.  Each student has first, last, age.  </p>
  
  <p><strong>Question:</strong>  How can we get all of the students in an array of arrays?  </p>
  
  <pre><code>students[0] =&gt; Array (
    ["first"] =&gt; "first name for 0",
    ["last"] =&gt; "last name for 0",
    ["age"] =&gt; "age for 0"
  ),
  students[1] =&gt; Array (
    ["first"] =&gt; "first name for 1",
    ["last"] =&gt; "last name for 1",
    ["age"] =&gt; "age for 1"
  ), 
  ...  
  </code></pre>
  
  <p><strong>Details</strong><br>
  For one student:  </p>
  
  <pre><code>&lt;input type="text" name="first"&gt;  
  &lt;input type="text" name="last"&gt;  
  &lt;input type="text" name="age"&gt;  
  </code></pre>
  
  <p>We can return multiple students in separate arrays like this:  </p>
  
  <pre><code>&lt;input type="text" name="students[first][]"&gt;  
  &lt;input type="text" name="students[last][]"&gt;  
  &lt;input type="text" name="students[age][]"&gt;  
  </code></pre>
  
  <p>which returns an array of firsts, lasts and ages  </p>
  
  <pre><code>students["first"] = [array of first names]
  students["last"] = [array of last names]
  students["age"] = [array of ages]  
  </code></pre>
  
  <p>Theoretically we can get all the info for a student by accessing the same index (say "3" for each array).  </p>
  
  <p>We do not want to programatically add an index in the form.<br>
  Do not want:  </p>
  
  <pre><code>&lt;input type="text" name="students[hardcoded_index][first]"&gt;  
  &lt;input type="text" name="students[hardcoded_index][last]"&gt;  
  &lt;input type="text" name="students[hardcoded_index][age]"&gt;  
  </code></pre>
  
  <p>If for any reason it matters, we are using Rails for views but can use form helpers or HTML.</p>