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?
To insert any custom code in any place, you may use
f.form_buffers.last
:Just be careful about the HTML structure. If you call this from
f.inputs
block, your code will be placed inside an<ol>
element. On the "form" level, you are inside a<form>
element.A little warning: As with any "undocumented feature" this method may change without warning in any new release.
Here's a slightly simplified form of @arsen7's answer:
which in my form looks like this:
And here's one that mimics ActiveAdmin's default style:
which looks like this:
Figured this out myself. I just needed to insert the html without any method calls, like so: