Module: Formtastic::SemanticFormHelper
- Defined in:
- lib/formtastic.rb
Overview
Wrappers around form_for (etc) with :builder => SemanticFormBuilder.
-
semantic_form_for(@post)
-
semantic_fields_for(@post)
-
semantic_form_remote_for(@post)
-
semantic_remote_form_for(@post)
Each of which are the equivalent of:
-
form_for(@post, :builder => Formtastic::SemanticFormBuilder))
-
fields_for(@post, :builder => Formtastic::SemanticFormBuilder))
-
form_remote_for(@post, :builder => Formtastic::SemanticFormBuilder))
-
remote_form_for(@post, :builder => Formtastic::SemanticFormBuilder))
Example Usage:
<% semantic_form_for @post do |f| %>
<%= f.input :title %>
<%= f.input :body %>
<% end %>
The above examples use a resource-oriented style of form_for() helper where only the @post object is given as an argument, but the generic style is also supported if you really want it, as is forms with inline objects (Post.new) rather than objects with instance variables (@post):
<% semantic_form_for :post, @post, :url => posts_path do |f| %>
...
<% end %>
<% semantic_form_for :post, Post.new, :url => posts_path do |f| %>
...
<% end %>
The shorter, resource-oriented style is most definitely preferred, and has recieved the most testing to date.
Please note: Although it’s possible to call Rails’ built-in form_for() helper without an object, all semantic forms must have an object (either Post.new or @post), as Formtastic has too many dependencies on an ActiveRecord object being present.
Constant Summary collapse
- @@builder =
Formtastic::SemanticFormBuilder