Insert a non-input row into a Formtasic form

Randy Burgess picture Randy Burgess · May 9, 2012 · Viewed 7.7k times · Source

I am using Formtastic 2.1.1 in Rails 3.2 (with Active Admin) and I want to insert a row into my form that does not have an input field present. Is this possible and what is the syntax in the Formtastic DSL to achieve this?

Here's an example:

form do |f|

    f.inputs "Model Info" do
      f.input :title
      f.input :published
      f.input :path
    end

end

I'd like to do something like this:

form do |f|

    f.inputs "Model Info" do
      f.input :title
      f.input :published
      f.input :path
      f.div "This is some important text that people using this form need to know"
    end

end

Has anyone done this with Formtastic before?

Answer

Randy Burgess picture Randy Burgess · May 10, 2012

Figured this out myself. I just needed to insert the html without any method calls, like so:

form do |f|

  f.inputs "Model Info" do
    f.input :title
    f.input :published
    f.input :path
  end

  f.inputs "Custom HTML Stuff" do
    "<div id=\"element-name\">
      Some kind of content
    </div>".html_safe
  end

end