Hello. I''m trying to add extra content (in this case a select box) to a form. I''ve search the API to see how this could be done and in http://api.rubyonrails.com/classes/ActionView/Helpers/ActiveRecordHelper.html#M000375 it says that "It''s also possible to add additional content to the form by giving it a block, such as..." but can''t seem to put that to work. Here is the code in new.rhtml (it''s similar to the example given in the ActiveRecordHelper): <% form(person, :action => "create") do |form| %> <% form << content_tag("b", "Company") %> <% form << collection_select("company", "id", @company, "id", "name") %> <% end %> Can anyone help me? Thanks in advance. Best regards, Hugo
On 5/16/05, Hugo Magalhaes <hugo.mag-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello. > I''m trying to add extra content (in this case a select box) to a form. > I''ve search the API to see how this could be done and in > http://api.rubyonrails.com/classes/ActionView/Helpers/ActiveRecordHelper.html#M000375 > it says that "It''s also possible to add additional content to the form > by giving it a block, such as..." but can''t seem to put that to work. > > Here is the code in new.rhtml (it''s similar to the example given in > the ActiveRecordHelper): > > <% form(person, :action => "create") do |form| %> > <% form << content_tag("b", "Company") %> > <% form << collection_select("company", "id", @company, "id", "name") %> > <% end %>This should be: <%= form(person, :action => "create" do |f| f << content_tag("b", "Company") f << collection_select("person", "company_id", @company, "id", "name" end %>> > Can anyone help me? > Thanks in advance. > > Best regards, > Hugo > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Hi! On Mon, 16 May 2005, Michael Koziarski wrote the following:> This should be: > > <%= > form(person, :action => "create" do |f| > f << content_tag("b", "Company") > f << collection_select("person", "company_id", @company, "id", "name" > end > %>...missing some closing parenthesis or am I wrong? bye Wolfgang
Thanks for yours anwser. Both of them provided useful information and yes Wolfgang, Michael missed one parenthesis. Adding the parenthesis made the solution work fine. Here is the sode that worked: <%= form(person, :action => "create") do |f| f << content_tag("b", "Company") f << collection_select("person", "company_id", @company, "id", "name" end %> Best regards, Hugo