Multiple dynamically generated form fields

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.