Answers.Body: <p>I know I'm a bit late to this, but I think it's because your <code>{{ loop.index }}</code> is not <strong><a href="https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable" rel="nofollow noreferrer">0-indexed</a></strong>, which is necessary for the array.  It should look like this:</p>
  
  <p><code>&lt;input type="hidden" name="fields[selections][{{ loop.index0 }}][col1]" value="{{ item.qty }} x {{ item.description }}"&gt;</code></p>
  
  <p>You also need an extra valueless <code>hidden</code> field above the loop to collect all the values into one array:</p>
  
  <p><code>&lt;input type="hidden" name="fields[selections]" value=""&gt;</code></p>
  
  <p>You can see a fuller example on how to format the HTML for all fields of all types on this <strong><a href="https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input" rel="nofollow noreferrer">StraightUpCraft</a></strong> page.  Scroll to the very bottom for tables.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-12T22:26:42.517Z
Answers.LastActivityDate: 2017-09-12T22:26:42.517Z
Answers.UserDisplayName: Ryan
Body: <p>I'm trying to submit a form containing items from a users' cart, using A&amp;M forms, but cannot seem to populate the table field with the items. I'm using the code below:</p>
  
  <pre><code>{% for item in cart.lineItems %}
      &lt;input type="hidden" name="fields[selections][{{loop.index}}][col1]" value="{{item.qty}} x {{item.description}}"&gt;
  {% endfor %}
  </code></pre>
  
  <p>For some reason, though, it's creating the rows in the table, but not actually populating it with any content. Any idea what to do to get it to work?</p>
  
  <p>Thanks!</p>
  
Tags: <plugin-amforms>
Title: A&M Form Table Field Submission
ThreadText: # A&M Form Table Field Submission
  
  (Asked by: username_0 on 2016-09-12)
  
  I'm trying to submit a form containing items from a users' cart, using A&M forms, but cannot seem to populate the table field with the items. I'm using the code below:
  
  ```
  {% for item in cart.lineItems %}
      <input type="hidden" name="fields[selections][{{loop.index}}][col1]" value="{{item.qty}} x {{item.description}}">
  {% endfor %}
  
  ```
  
  For some reason, though, it's creating the rows in the table, but not actually populating it with any content. Any idea what to do to get it to work?
  
  Thanks!
  
  **Tags:** plugin-amforms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-12. Score: 1
  
  I know I'm a bit late to this, but I think it's because your `{{ loop.index }}` is not **[0-indexed](https://twig.symfony.com/doc/2.x/tags/for.html#the-loop-variable)**, which is necessary for the array. It should look like this:
  
  `<input type="hidden" name="fields[selections][{{ loop.index0 }}][col1]" value="{{ item.qty }} x {{ item.description }}">`
  
  You also need an extra valueless `hidden` field above the loop to collect all the values into one array:
  
  `<input type="hidden" name="fields[selections]" value="">`
  
  You can see a fuller example on how to format the HTML for all fields of all types on this **[StraightUpCraft](https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input)** page. Scroll to the very bottom for tables.
  
  
  ---
  
  