[Rails] submitting forms help

Peter Michaux
Sun, 09 Apr 2006 04:05:42 -0000

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


On 4/8/06, Manish Shah <mnshah@gmail.com> wrote:
> I cant seem to figure this problem out and i was hoping someone could help
> me out.
>
> I have a page with a list of forms.  I would like the user to be able to
> submit each form individually, or submit them all at once, to a different
> action (bascially, one that will do batch processing of all the forms).
>
> Is this possble?  Please help.
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>