beastlyCoder
beastlyCoder

Reputation: 2401

Adding forms based on user button clicks

I was wondering if there were any strategies to adding forms based on a button a user clicked. For example, lets say I have a form with artist, title, and genre. Then i have a button under those forms that say 'add another song', then it should display another set of fields of artist title, and genre. What are some strategies I can go about achieving this? Is there any ruby specific functions I can use, or am I stuck having to use something like JavaScript? Thanks :)

Upvotes: 0

Views: 46

Answers (1)

Hossam Khamis
Hossam Khamis

Reputation: 1202

What you are looking for is called nested attributes.

You will also need to use JavaScript as well if you need the number of ( artist, title, and genre ) forms to be dynamic (set by user in the browser using a button).

you can find an example about this type of forms in this repository

Upvotes: 1

Related Questions