Form helper in a content_tag

Hi,

I want to add a form helper in a content_tag like this:

def custom_field(form, attribute_name, form_helper, message = “”)
error = form.object.errors.get(attribute_name).present?
klasses = [“clearfix”]
klasses << “error” if error

content_tag :div, :class => klasses.join(", ") do
  form.label :attribute_name
  content_tag(:div, :class => :input) do
    form.send(form_helper, attribute_name, :class => (error ?

“error” : nil))
content_tag :span, :class => “help-inline” do
form.object.errors.get(attribute_name)
end
end
end
end

This works but the form helper aren’t rendered. What do I have to do to
render the form helpers??

Gregory

Here is the solution:

def custom_field(form, attribute_name, form_helper, message = “”)
error = form.object.errors.get(attribute_name).present?
klasses = [“clearfix”]
klasses << “error” if error

content_tag :div, :class => klasses.join(", ") do
  concat(form.label(attribute_name) +
    content_tag(:div, :class => :input) do
      concat(form.send(form_helper, attribute_name, :class => (error 

? “error” : nil)) +
content_tag(:span, :class => “help-inline”) do
concat(form.object.errors.get(attribute_name).join(". "))
end)
end)
end
end

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