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, as are 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 %>
Constant Summary collapse
- FIELD_ERROR_PROC =
Override the default ActiveRecordHelper behaviour of wrapping the input. This gets taken care of semantically by adding an error class to the LI tag containing the input.
proc do |html_tag, instance_tag| html_tag end
- @@builder =
::Formtastic::SemanticFormBuilder
- @@default_field_error_proc =
nil
Instance Method Summary collapse
- #semantic_remote_form_for_wrapper(record_or_name_or_array, *args, &proc) ⇒ Object (also: #semantic_remote_form_for)
- #with_custom_field_error_proc(&block) ⇒ Object
Instance Method Details
#semantic_remote_form_for_wrapper(record_or_name_or_array, *args, &proc) ⇒ Object Also known as: semantic_remote_form_for
1735 1736 1737 1738 1739 1740 1741 1742 1743 |
# File 'lib/formtastic.rb', line 1735 def semantic_remote_form_for_wrapper(record_or_name_or_array, *args, &proc) = args. if self.respond_to? :remote_form_for semantic_remote_form_for_real(record_or_name_or_array, *(args << ), &proc) else [:remote] = true semantic_form_for(record_or_name_or_array, *(args << ), &proc) end end |
#with_custom_field_error_proc(&block) ⇒ Object
1727 1728 1729 1730 1731 1732 1733 |
# File 'lib/formtastic.rb', line 1727 def with_custom_field_error_proc(&block) @@default_field_error_proc = ::ActionView::Base.field_error_proc ::ActionView::Base.field_error_proc = FIELD_ERROR_PROC result = yield ::ActionView::Base.field_error_proc = @@default_field_error_proc result end |