The proper usage of form_tag nowadays is: <% form_tag do %> blah blah blah <% end %> Supposing I want to use form_tag inside a helper, e.g. def search_form form_tag do ... ??? ... end end what would I put inside the block? In my other helpers, I build up a string and return it. - donald --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr (Library) wrote:> The proper usage of form_tag nowadays is: > > <% form_tag do %> > blah blah blah > <% end %> > > Supposing I want to use form_tag inside a helper, e.g. > > def search_form > form_tag do > ... ??? ... > end > end > > what would I put inside the block? In my other helpers, I build up a > string and return it. > > - donald >I''ve been wondering this too! Nothing I''ve done seems to work. Only downside I''ve found to the new way. - Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Ball, Donald A Jr (Library) wrote: > > The proper usage of form_tag nowadays is: > > > > <% form_tag do %> > > blah blah blah > > <% end %> > > > > Supposing I want to use form_tag inside a helper, e.g. > > > > def search_form > > form_tag do > > ... ??? ... > > end > > end > > > > what would I put inside the block? In my other helpers, I > build up a > > string and return it. > > > > - donald > > > > I''ve been wondering this too! Nothing I''ve done seems to work. > Only downside I''ve found to the new way.Poking through the source, I note that the form_tag method uses the concat method if a block is given, which looks like it ends up writing directly to _erbout (via an eval call - which would seem to be an overly slow way of going about it...) Absent a quick redef of that method around the form_tag call, I don''t see a way to use form_tag inside a helper. Tch. - donald --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr (Library) wrote:> The proper usage of form_tag nowadays is: > > <% form_tag do %> > blah blah blah > <% end %> > > Supposing I want to use form_tag inside a helper, e.g. > > def search_form > form_tag do > ... ??? ... > end > end > > what would I put inside the block? In my other helpers, I build up a > string and return it. > > - donaldI know this post is too old, but I haven''t seen anyone answering this question, so here I go. I found I could use a form_tag inside a helper method this way: def search_form form_tag do ( text_field_tag( :name ) + text_field_tag( :lastname ) ) end I think there should be a cleaner way, but at least this works. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That didn''t quite work for me, but I have made it work using concat: def search_form form_tag do concat ( text_field_tag( :name ) + text_field_tag( :lastname ) ) end On May 26, 5:41 am, Pablo Gonzalez <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ball, Donald A Jr (Library) wrote: > > > > > > > The proper usage of form_tag nowadays is: > > > <% form_tag do %> > > blah blah blah > > <% end %> > > > Supposing I want to use form_tag inside a helper, e.g. > > > def search_form > > form_tag do > > ... ??? ... > > end > > end > > > what would I put inside the block? In my other helpers, I build up a > > string and return it. > > > - donald > > I know this post is too old, but I haven''t seen anyone answering this > question, so here I go. > > I found I could use a form_tag inside a helper method this way: > > def search_form > form_tag do > ( > text_field_tag( :name ) + > text_field_tag( :lastname ) > ) > end > > I think there should be a cleaner way, but at least this works. > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Tyler wrote:> That didn''t quite work for me, but I have made it work using concat: > > def search_form > form_tag do > concat ( > text_field_tag( :name ) + > text_field_tag( :lastname ) > ) > endYou shouldn''t need the concat. It''s not actually doing anything. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.