Custom form builder

Hi,

I am trying to create a custom form builder but got the following error:
wrong argument type Class (expected Module)

To create a form builder I have to subclass
ActionView::Helpers::FormBuilder. So, I guess, it must be a class and
not a
module or maybe a class wrapped inside a module…

Here is the idea:

The helper (/app/helpers/custom_form_helper.rb):

class CustomFormHelper < ActionView::Helpers::FormBuilder

def datalist_for(method, choices, options = {})
 ...     # I'd like to render a partial here with :locals => {:list 

=>
choices, :name => @object_name + “[_#{method}]”}
end
end

The partial (app/view/shared):

<input type=“text” name=<%= name %> list=“list”>

<% choices.each do |elem| %>
<option value=<%= elem %> >
<% end %>

The view:

<%= form_for(:moove, :builder => “CustomFormHelper” :url => {:action =>
‘create’}) do |f| %>





<%= f.datalist_for(:sport, @sports)%>

<% end %>

Thank you in advance for your help,

Alexandre

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs