Module: Formtastic::Helpers::InputsHelper
- Included in:
- FormBuilder
- Defined in:
- lib/formtastic/helpers/inputs_helper.rb
Overview
#inputs is used to wrap a series of form items in a <fieldset>
and <ol>
, with each item
in the list containing the markup representing a single #input.
#inputs is usually called with a block containing a series of #input methods:
<%= semantic_form_for @post do |f| %>
<%= f.inputs do %>
<%= f.input :title %>
<%= f.input :body %>
<% end %>
<% end %>
The HTML output will be something like:
<form class="formtastic" method="post" action="...">
<fieldset>
<ol>
<li class="string required" id="post_title_input">
...
</li>
<li class="text required" id="post_body_input">
...
</li>
</ol>
</fieldset>
</form>
It's important to note that the semantic_form_for
and #inputs blocks wrap the
standard Rails form_for
helper and FormBuilder, so you have full access to every standard
Rails form helper, with any HTML markup and ERB syntax, allowing you to "break free" from
Formtastic when it doesn't suit:
<%= semantic_form_for @post do |f| %>
<%= f.inputs do %>
<%= f.input :title %>
<li>
<%= f.text_area :body %>
<li>
<% end %>
<% end %>
Constant Summary collapse
- SKIPPED_COLUMNS =
Which columns to skip when automatically rendering a form without any fields specified.
[:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version]