views:

28

answers:

1

I am making a photo upload form. Before they begin, they have two choices. They can create a new gallery, OR they can choose from an existing gallery.

I was thinking the best way to lay this out would be two have two forms. One for the create one that would take them to the create page. That's easy, and practically done.

But the second form, I need to grab the gallery name in a select box and apply it to an add_photos_to_gallery form - which is tricky for me. Do I?

a. Make a temp variable for this form and pass it to the controller, and then generate the form from what they choose? If so, how could I do that?

b. Use jquery and somehow manipulate the DOM to create a form? I got some ideas..

c. Realize I'm too dumb to know something way better and more obvious?

+1  A: 

roughly speaking the way I would approach this is with one form,

to populate the select tag, i am assuming you create a named scope or association in your user model, eg

has_many :galleries

and populate the select tag with it

 <%= select_tag "add_photos_to_gallery", @user.galleries, :include_blank => true %>

and if the params[:add_photos_to_gallery] is blank, create a new album otherwise add it to the selected gallery.

Or you could include a checkbox to toggle on or off the select tag based on if they want to use an existing gallery or not.

Jed Schneider