Hi, I''m wondering if there is any way to specify the id of a form tag with the start_form_tag helper. I''ve tried playing around with ", id=>"marginForm" " and also inclosing both the action variable and id variable in curley brackets. The Rails API doesn''t off much help for a n00b like me. It''s probably really easy but any help you guys can offer would really be appreciated. Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060712/a3418406/attachment.html
<%= form_tag :action => ''update'', :id => "marginForm" %> Note that you can find the answer by looking at <http:// api.rubyonrails.com/classes/ActionView/Helpers/ FormTagHelper.html#M000491> and then following the ActionController::Base#url_for link to <http://api.rubyonrails.com/ classes/ActionController/Base.html#M000202>, where an example shows the use of :id. Also note that start_form_tag is an alias to form_tag. - dan -- Dan Kohn <mailto:dan@dankohn.com> <http://www.dankohn.com/> <tel:+1-415-233-1000> On Jul 11, 2006, at 8:26 PM, Chris Lloyd wrote:> Hi, > > I''m wondering if there is any way to specify the id of a form tag > with the start_form_tag helper. I''ve tried playing around with ", > id=>"marginForm" " and also inclosing both the action variable and > id variable in curley brackets. The Rails API doesn''t off much help > for a n00b like me. It''s probably really easy but any help you guys > can offer would really be appreciated. > > Chris > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060712/838f5df4/attachment.html
Umm thanks but I don''t think I explained myself properly. What I would like it to generate is:> <form action="/admin/pages/create/" method="post" id="marginForm" > > > at the moment using what you suggested it generates:> <form action="/admin/pages/create/marginForm" method="post"> > > I think I might to use an HTML helper or even use the url_for command thatyou suggested, but I would prefer to use an actual Rails helper to construct the entire form tag just so its easier to update and modify in the future.> <form action="<%= url_for :action => "create" %>" method="post" id="marginForm" > > > Thanks for you help anyway. ^_^Chris On 7/12/06, Dan Kohn <dan@dankohn.com> wrote:> > <%= form_tag :action => ''update'', :id => "marginForm" %> > Note that you can find the answer by looking at < > http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000491> > and then following the ActionController::Base#url_for link to < > http://api.rubyonrails.com/classes/ActionController/Base.html#M000202>, > where an example shows the use of :id. > > Also note that start_form_tag is an alias to form_tag. > > - dan > -- > Dan Kohn <mailto:dan@dankohn.com <dan@dankohn.com>> > <http://www.dankohn.com/> <tel:+1-415-233-1000> > > > > On Jul 11, 2006, at 8:26 PM, Chris Lloyd wrote: > > Hi, > > I''m wondering if there is any way to specify the id of a form tag with the > start_form_tag helper. I''ve tried playing around with ", id=>"marginForm" " > and also inclosing both the action variable and id variable in curley > brackets. The Rails API doesn''t off much help for a n00b like me. It''s > probably really easy but any help you guys can offer would really be > appreciated. > > Chris > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- 3202-4 Sydney University Village 90 Carillon Avenue Newtown 2042 NSW, Australia T: 9036-4302 M: 04241-21343 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060712/c9f7b346/attachment-0001.html
Chris Lloyd wrote:> Umm thanks but I don''t think I explained myself properly. What I would > like > it to generate is: > >> <form action="/admin/pages/create/" method="post" id="marginForm" > >>How about: form_tag ({:action => ''create''}, :id => ''marginForm'') Ian. -- Posted via http://www.ruby-forum.com/.
Oh wow, thanks heaps. That works perfectly. This might just be me not having much experience with either Ruby or Rails (coming from PHP), but I think that Ruby (with Rails) is the thinking man''s (or woman''s) language. If I put in 30 seconds thought about how I could do something in Rails I can do it in about 1/2 hour. Whereas you don''t really need to think at all with PHP but it''ll take you a day to code anything. Thanks again Ian and Dan. Regards, Chris On 7/12/06, Ian Webb <ian@funkyfrog.net> wrote:> > Chris Lloyd wrote: > > Umm thanks but I don''t think I explained myself properly. What I would > > like > > it to generate is: > > > >> <form action="/admin/pages/create/" method="post" id="marginForm" > > >> > > How about: > > form_tag ({:action => ''create''}, :id => ''marginForm'') > > Ian. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060712/f3cefe2d/attachment.html
Chris - the problem you ran into is that often that you pass a helper a hash, and sometimes you''ve got other hashes within that hash. If there''s only one thing in each hash, you can pass them as a, b, c; once you''re actually trying to pass in several, you need to delineate the hashes: a, {b,d}, c I still run into this every now and then. The API reference is always good reference to show you what goes where, though. On 12/07/06, Chris Lloyd <christopher.lloyd@gmail.com> wrote:> Oh wow, thanks heaps. That works perfectly. > > This might just be me not having much experience with either Ruby or Rails > (coming from PHP), but I think that Ruby (with Rails) is the thinking man''s > (or woman''s) language. If I put in 30 seconds thought about how I could do > something in Rails I can do it in about 1/2 hour. Whereas you don''t really > need to think at all with PHP but it''ll take you a day to code anything. > > Thanks again Ian and Dan. > > Regards, > > Chris > > > On 7/12/06, Ian Webb <ian@funkyfrog.net> wrote: > > Chris Lloyd wrote: > > > Umm thanks but I don''t think I explained myself properly. What I would > > > like > > > it to generate is: > > > > > >> <form action="/admin/pages/create/" method="post" id="marginForm" > > > >> > > > > How about: > > > > form_tag ({:action => ''create''}, :id => ''marginForm'') > > > > Ian. > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >