# Multiple dynamically generated form fields

**URL:** <https://www.ruby-forum.com/t/multiple-dynamically-generated-form-fields/170031>\
**Category:** Rails\
**Created:** [June 11, 2009, 2:39pm UTC](https://www.ruby-forum.com/t/multiple-dynamically-generated-form-fields/170031 "2009-06-11T14:39:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [June 11, 2009, 2:39pm UTC](https://www.ruby-forum.com/t/multiple-dynamically-generated-form-fields/170031/1 "2009-06-11T14:39:37Z")

</div>

Just wondering what the best “Rails way” to do this would be…

I have a form that uses an auto complete text box and a

 that holds  
n number of selections from the text box. The 
 is made up of  
multiple - each with the id set to the modelname\_id. When the user  
submits the form, I parse through the 
  - elements and populate two  
hidden form fields (one for each type of model in the 
) with a ,  
separated string then on the server I split the fields and create my  
database records. This all works fine but it doesn’t seem “right”

How should I be doing this? I thought about creating hidden input  
fields (one for each

    - ) or create input fields in the 
    - and  
disabling and styling them to look the way I need…? Seems like rails  
would be able to handle the array of fields better then the , delimited  
fields I’m currently using…??

Not sure of the best approach.

Thanks.
