Michael Xenakis
2006-Jun-07 08:50 UTC
[Rails] Specifying a Form name using start_/form_tag
Hey all. I''m trying use the form tag(s) to create a named / id''d form. I.e., I need to use JS to access the form via the DOM and submit it - support for a reusable navigation component which will persist app state on each jump. However, from reading the form_tag APIs and searching google, I don''t see where either :name or :id is an option which can be passed into the form* tags. And having tried a number of permutations for specifying the additional parameter based on the conventions for other tags all result in error. Any thoughts? Thanks much, mx. Michael Xenakis Architect ?bermind, Inc. 206.290.3362 xenakis@ubermind.com http://www.ubermind.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060606/ab059f98/attachment-0001.html
I struggled with this same problem for a while. The issue, as you say, is how to specify the DOM id of a form when using the form_tag method. This is helpful when using things like ''observe_form'', which requires the form''s ID. Try this: <%= form_tag( {:action=>''xyz''}, {:id=>''my_form_id''} ) %> *** The key is to surround your arguments with parenthesis. *** I could swear that passing multiple hashes without surrounding parens works in many other methods, so I''m not sure why it''s a problem here. I hope this helps anyone who''s struggled with this. -Ben Ridout -- 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 -~----------~----~----~----~------~----~------~--~---
Ruby doesn''t know if it''s a hash or a block - that''s why you need parentheses. ie: foo.bar { .... } the intent of the braces is ambiguous (and is most likely a block), but foo.bar( { .... } ) clearly is taking a hash as an argument. On Jun 8, 4:34 pm, Bne Ridout <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I struggled with this same problem for a while. The issue, as you say, > is how to specify the DOM id of a form when using the form_tag method. > This is helpful when using things like ''observe_form'', which requires > the form''s ID. > > Try this: > > <%= form_tag( {:action=>''xyz''}, {:id=>''my_form_id''} ) %> > > *** The key is to surround your arguments with parenthesis. *** > > I could swear that passing multiple hashes without surrounding parens > works in many other methods, so I''m not sure why it''s a problem here. > > I hope this helps anyone who''s struggled with this. > > -Ben Ridout > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---