Hello Started with Rails just a couple days ago and got stuck in two ways - I like it (and would like to learn more) and cannot really figure out how to use the submit_tag within the form_tag to initiate alternative actions depending on which submit was chosen. One submit should function exactly like the edit/update action from the initial scaffold while the other should do the same plus change some additional fields. Thanks a lot, Alex
on 2006-04-27 11:22
on 2006-04-27 17:21
Hello again, actually found a solution from Peter in early April. Works fine. Cheers, Alex "Posted by Peter M. (Guest) on 09.04.2006 06:07 I think you can only submit one form at a time. But there is a solution. Make your whole page one big form that submits to a particular action. For each "sub-form" make a button with a unique name. <button name="little_form_1"> tags or <input type=button name="little_form_1>. You don't use submit tags for this. For the entire form make a button with a unique name. <button name="all_forms"> In the action that will process the form you will make a if else statement if params[:all_forms] elseif params[:little_form_1] end The above syntax may be a bit suspect but I've used something like this before. I think it is nice an clean. I've found that it is best if forms submit their data back to the same action that created the form. This makes life easier. It also helps a lot with validation and redirects. Peter"