Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmitting form elements with the same name
    text
    copied!<p>I have a form which allows the user to create extra "rows" using JQuery (using .clone) so that they can decide how many of the same information they need to submit. My issue is that I cannot work out how to access these form items within my controller.</p> <p>the form that is being submitted may look like this</p> <pre><code>&lt;input type="text" name="Amount" id="Amount"&gt; &lt;select name="Item"&gt; &lt;option value="1"&gt;Item 1"&lt;/option&gt; &lt;option value="2"&gt;Item 2"&lt;/option&gt; &lt;option value="3"&gt;Item 3"&lt;/option&gt; &lt;/select&gt; &lt;input type="text" name="Amount" id="Amount"&gt; &lt;select name="Item"&gt; &lt;option value="1"&gt;Item 1"&lt;/option&gt; &lt;option value="2"&gt;Item 2"&lt;/option&gt; &lt;option value="3"&gt;Item 3"&lt;/option&gt; &lt;/select&gt; &lt;input type="text" name="Amount" id="Amount"&gt; &lt;select name="Item"&gt; &lt;option value="1"&gt;Item 1"&lt;/option&gt; &lt;option value="2"&gt;Item 2"&lt;/option&gt; &lt;option value="3"&gt;Item 3"&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Basically, the block between <code>input</code> and the select could be repeated an infinite number of times. When I submit to the controller I am then using <code>FormCollection form</code> to access the form elements. from there I am unsure how I can access the items that have been submitted. I thought of using a for loop and then accessing them via something like form["Amount"][i] but obviously that is not going to work.</p> <p>Am I going about this the right way and if so, does anyone have any suggestions about how this might work?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload