Request param type of array

Hello.

I have tested such form:

<form method='POST'>   <input type='hidden' name='myfield' value='value1'>   <input type='hidden' name='myfield' value='value2'>   <input type='submit' name='_submit' value='OK'> </form>

Hi,

<form method='POST'>   <input type='hidden' name='myfield' value='value1'>   <input type='hidden' name='myfield' value='value2'>   

try to use the name 'myfield'. That way you are telling rails that you are expecting an array and that you want to access that param as such. After that it should be working as you'd expect.

Guess the rationale after that is that since there is no clear way to tell in plain html that you are going to use a multivalued field, you should be checking always at the backend if you have a single or multivalued param. Also you could get wrong results when having a duplicated name in a view (as is the case sometimes).

By forcing a special syntax, you can be sure you are getting what you are asking for. Even if you are finally passing a single value you can safely access it as an array.

regards,

javier ramírez

I have found variant to send array of values and get them from params variable:

<form method='POST'>   <input type='hidden' name='myfield' value='value1'>   <input type='hidden' name='myfield' value='value2'>   <input type='submit' name='_submit' value='OK'> </form>

Thanks :slight_smile: