Stack Exchange
customized form_for tag in rails
I want to make a table within a form by making a new form_tag. The following code in ApplicationHelper fails:
module ApplicationHelper

class TabularFormBuilder < ActionView::Helpers::FormBuilder 
   # ... code to insert <tr> tags </tr> 
end

def tabular_form_for(name, object = nil, options = nil, &proc) 
   concat("<table>", proc.binding) 
   form_for(name, 
   object, 
   (options||{}).merge(:builder => TabularFormBuilder), 
   &proc) 
   concat("</table>", proc.binding) 
  end
end

The view I use is:
<h1>New project</h1>
<% tabular_form_for :project, :builder => ApplicationHelper::TabularFormBuilder do |f| %>
  <%= f.error_messages %>
  <%= f.text_field :name %>
  <%= f.text_area :description %>
  <%= f.text_field :location %>
  <%= f.submit 'Create' %>
<% end %>

The error I get is:
NoMethodError in Projects#new
   Showing app/views/projects/new.html.erb where line #5 raised:
   undefined method `errors' for {:builder=>ApplicationHelper::TabularFormBuilder}:Hash
Any ideas how to make this custom tag work?

hi poseid,
can u send some details on how you are calling this method and about parameters that you are passing
cheers,
sameera

Is this posted verbatim? Because your second block needs to be within the closing end tag for it to access the FormBuilder class right?
I found the following tutorial which might help:
http://ramblingsonrails.com/how-to-make-a-custom-form-builder-in-rails
