This should be simple to do, but I can’t seem to find any documentation for it. I am using Rails 3.2 and simple_form. I want to make a form where a user can submit multiple rows of data at once. For example, the form will be:
Animal type: __ Name: _____
I want them to be able submit multiple rows. So they can do:
Animal type: Dog Name: Fido
Animal type: Dog Name: Charley
Animal type: Cat Name: Logan
etc.
The goal is to be able to submit as many items as the user has, with new input rows being created through javascript. I just don’t know how the code is written for the form submit.
You’re going to need to do something with javascript. Here’s some code for a jQuery implementation of a similar feature (only for 1 field, you need to adjust accordingly for two):
This assumes you have a hidden input on your form, presumably with a value of 0 or 1 and an id of id_count. Also need an a tag (link) with an id of linkToClick.
Give that a try and let me know how it works.