I am using the form_tag_helper to create a form, but I want to give it
an ID so I can style the elements within the form.  I currently have
the following:
        <% form_tag :controller => ''my_controller'',
:action =>
''my_action'' do %>
          <input class="actionButton" type="submit"
value="Submit" />
        <% end %>
I tried this:
        <% form_tag :id => ''xyz'', :controller =>
''my_controller'', :action => ''my_action''
do %>
          <input class="actionButton" type="submit"
value="Submit" />
        <% end %>
This compiles and runs ok with no errors, but it treats the ID= as a
parameter for my URL - not what I want.  Is there a way to use
form_tag to generate HTML similar to this:
          <form id="xyz" action="/my_directory/my_action"
method="post">
Thanks,
Steve J.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
<% form_tag {:controller => "..."}, {:id => "xyz"}
%>
Try it?
On Thu, Feb 5, 2009 at 11:49 AM, srj
<stephenr.jacobs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I am using the form_tag_helper to create a form, but I want to give it
> an ID so I can style the elements within the form.  I currently have
> the following:
>
>        <% form_tag :controller => ''my_controller'',
:action =>
> ''my_action'' do %>
>          <input class="actionButton" type="submit"
value="Submit" />
>        <% end %>
>
> I tried this:
>
>        <% form_tag :id => ''xyz'', :controller =>
> ''my_controller'', :action =>
''my_action'' do %>
>          <input class="actionButton" type="submit"
value="Submit" />
>        <% end %>
>
> This compiles and runs ok with no errors, but it treats the ID= as a
> parameter for my URL - not what I want.  Is there a way to use
> form_tag to generate HTML similar to this:
>
>          <form id="xyz"
action="/my_directory/my_action"
> method="post">
>
> Thanks,
>
> Steve J.
> >
>
-- 
TWRUG Blog:
http://blog.rubyonrails.org.tw
CFC on Rails:
http://zusocfc.blogspot.com
Only two surfaces of a box:
http://blog.pixnet.net/zusocfc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Steve!
     Try this   <%= form_tag :action => ''my_action'', :id
=>''xyz'' %> and
I think this manual will be helpful to 
you.http://blog.invisible.ch/files/rails-reference-1.1.html#htmlforms .
enjoy ! have a great day.
cheers,
shankar.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> I am using the form_tag_helper to create a form, but I want to give it > an ID so I can style the elements within the form. I currently have > the following:Style things with classes unless you must use IDs. I can''t think of a reason. Rails is so flexible that, before you know it, you will be cloning this form and en-partialling it into your page more than once, and IDs must be unique to their document... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I did try with class= instead of id=, but I get the exact same result On Feb 4, 11:01 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am using the form_tag_helper to create a form, but I want to give it > > an ID so I can style the elements within the form. I currently have > > the following: > > Style things with classes unless you must use IDs. I can''t think of a reason. > > Rails is so flexible that, before you know it, you will be cloning this form and > en-partialling it into your page more than once, and IDs must be unique to their > document...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Look at the Api. You need to supply two hashed rather than one. The second has HTML options. The first is the URL Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 2:49 PM, srj <stephenr.jacobs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am using the form_tag_helper to create a form, but I want to give it > an ID so I can style the elements within the form. I currently have > the following: > > <% form_tag :controller => ''my_controller'', :action => > ''my_action'' do %> > <input class="actionButton" type="submit" value="Submit" /> > <% end %> > > I tried this: > > <% form_tag :id => ''xyz'', :controller => > ''my_controller'', :action => ''my_action'' do %> > <input class="actionButton" type="submit" value="Submit" /> > <% end %> > > This compiles and runs ok with no errors, but it treats the ID= as a > parameter for my URL - not what I want. Is there a way to use > form_tag to generate HTML similar to this: > > <form id="xyz" action="/my_directory/my_action" > method="post"> > > Thanks, > > Steve J. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That won''t work. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 3:00 PM, Shankar Ganesh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi Steve! > > Try this <%= form_tag :action => ''my_action'', :id =>''xyz'' %> and > I think this manual will be helpful to > you.http://blog.invisible.ch/files/rails- > reference-1.1.html#htmlforms . > > enjoy ! have a great day. > > cheers, > shankar. > > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Steve, Have you tried this url(http://blog.invisible.ch/files/rails-reference-1.1.html#htmlforms . ) ? shankar. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That''s not true. Ids are perfectly valid. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 3:01 PM, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> >> I am using the form_tag_helper to create a form, but I want to >> give it >> an ID so I can style the elements within the form. I currently >> have >> the following: > > Style things with classes unless you must use IDs. I can''t think of > a reason. > > Rails is so flexible that, before you know it, you will be cloning > this form and > en-partialling it into your page more than once, and IDs must be > unique to their > document... > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks everyone for all the help  . . .
When I tried it like this, I got a compile error:
<% form_tag ( {:controller => ''my_controller'', :action
=>
''my_action'' }, {:id => ''xyz''}) do %>
When I removed the second set of braces  { }, like this, it works!!!
<% form_tag ( {:controller => ''my_controller'', :action
=>
''my_action'' }, :id => ''xyz'') do %>
Thanks again, I appreciate all the suggestions!
On Feb 4, 11:14 pm, Shankar Ganesh
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Steve, Have you tried this
> url(http://blog.invisible.ch/files/rails-reference-1.1.html#htmlforms.
> ) ?
>
> shankar.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Steve can you tell me when you are getting error and what error? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I just added the extra braces back in so I could see the error again, but now it does not complain - I must have had something extra or something missing. So I guess it works both ways. On Feb 4, 11:21 pm, Shankar Ganesh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Steve can you tell me when you are getting error and what error? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---