How to make two forms on the same page?


#1

I can get the forms to be displayed, but i want to have only one
“create” button. i’ve tried everything i can think of…


#2

On 3/9/06, jon removed_email_address@domain.invalid wrote:

I can get the forms to be displayed, but i want to have only one “create”
button. i’ve tried everything i can think of…

If I understand you, you want to have something like…

[form1]
[field1]
[field2]
[end_form1]
[form2]
[field3]
[submit]
[end_form2]

…and have the submit button submit both form1 and form2?

That’s not something regulation HTML is capable of*. Is there a reason
you
can’t you just combine the forms?

  • You /could/, technically, do this in JavaScript with onsubmit(), but
    it’s error-prone and - at best - only works with JavaScript-enabled
    browsers.

#3

How do you have 2 forms on the same page with 2 diiferent submit tags?


#4

Well they cross paths when i render a partial but when they are
currently on the same page they have the following code:

Leave a Reply
<%= form_tag :action => “comment”, :id => @post %>
<%= render :partial => ‘commentform’ %>

<%= submit_tag "Comment!" %>

and

<%= form_tag :action => ‘search’ %>

<%= text_field_tag 'search' , params[:search], "size" =>"20" %> <%= submit_tag 'Search' %>

<%= end_form_tag %>

The 1st form Leave a reply gets called regardless of which submit button
i click.


#5

John B. wrote:

How do you have 2 forms on the same page with 2 diiferent submit tags?

Can you post the rhtml you’re currently trying ?

Alan


#6

John B. wrote:

Well they cross paths when i render a partial but when they are
currently on the same page they have the following code:

Leave a Reply
<%= form_tag :action => “comment”, :id => @post %>
<%= render :partial => ‘commentform’ %>

<%= submit_tag "Comment!" %>

and

<%= form_tag :action => ‘search’ %>

<%= text_field_tag 'search' , params[:search], "size" =>"20" %> <%= submit_tag 'Search' %>

<%= end_form_tag %>

The 1st form Leave a reply gets called regardless of which submit button
i click.

There’s no end_form_tag after the first form ?

Alan


#7

problem solved!

I’m having 1 of those days, time to finish up for the day i think

Thanks


#8

<…>

<%= submit_tag ‘Search’ %>


<%= end_form_tag %>

The 1st form Leave a reply gets called regardless of which submit button
i click.

Where’s your end_form_tag for the first form?

Regards,
Rimantas

http://rimantas.com/