# Two form\_tag's

**URL:** <https://www.ruby-forum.com/t/two-form-tags/131374>\
**Category:** Rails\
**Created:** [March 8, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/two-form-tags/131374 "2008-03-08T23:51:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abusiek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@abusiek](https://www.ruby-forum.com/u/abusiek)\
**Post date:** [March 8, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/two-form-tags/131374/1 "2008-03-08T23:51:58Z")

</div>

Hi!

I’m new with ruby on rails and I’ve faced such a problem:

In layout I have one form:

\<%= form\_tag ({:controller =\> ‘kontakty’, :action =\>  
‘search’}, :method =\> ‘get’) %\>  
  
  
\<%= text\_field\_tag ‘s’%\>  
Szukaj  
  
\<%= form\_tag %\>

And in view for action ‘Create’ (where you can add new record):

\<%= form\_tag :controller =\> ‘kontakty’, :action =\> ‘new’, :method =\>  
‘post’ %\>

Imiê:  
\<%= text\_field ‘contact’, ‘name’, :class =\> ‘s’ %\>

  

Nazwisko:  
\<%= text\_field ‘contact’, ‘surname’, :class =\> ‘s’ %\>

  

Data urodzenia:  
\<%= calendar\_date\_select\_tag “contact[birth]”,  
“nil”, :year\_range =\> 1900…2008 %\>

  
  
\<%= form\_tag %\>

When I’m submitting the second form all parameters are sent two the  
first one and action from the firts one is executed.

Any ideas why? (and sorry for my poor english ☹ )

---

<div class="post-metadata">

**Author:** ![abusiek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@abusiek](https://www.ruby-forum.com/u/abusiek)\
**Post date:** [March 9, 2008, 12:06am UTC](https://www.ruby-forum.com/t/two-form-tags/131374/2 "2008-03-09T00:06:40Z")

</div>

sorry for stupid question, I was reading wrong tutorial 😉

---

<div class="post-metadata">

**Author:** ![abusiek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@abusiek](https://www.ruby-forum.com/u/abusiek)\
**Post date:** [March 9, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/two-form-tags/131374/3 "2008-03-09T18:21:57Z")

</div>

On 8 Mar 2008, at 22:50, abusiek wrote:

> ```
> <!-- <input id="s" type="text" name="s" value="" /> -->
> 
> ```
> 
> Imiê: When I'm submitting the second form all parameters are sent two the first one and action from the firts one is executed.
> 
> Any ideas why? (and sorry for my poor english ☹ )

It’s probably confused by the way you’re openening lots of form tags  
and not closing them (have you looked at the generated html 🙂 )

What you should be doing with form tag is  
\<% form\_tag(…) do %\>

\<% end %\>

With older versions of rails it was different, but even then at the  
end of the form you needed \<%= end\_form\_tag %\> at the end.  
Fred
