Class: Formtastic::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
Helpers::ButtonsHelper, Helpers::ErrorsHelper, Helpers::InputHelper, Helpers::InputsHelper, HtmlAttributes
Defined in:
lib/formtastic/form_builder.rb

Direct Known Subclasses

SemanticFormBuilder

Constant Summary

Constants included from Helpers::ErrorsHelper

Helpers::ErrorsHelper::INLINE_ERROR_TYPES

Constants included from Helpers::InputsHelper

Helpers::InputsHelper::SKIPPED_COLUMNS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ErrorsHelper

#inline_errors_for, #semantic_errors

Methods included from Helpers::Reflection

#reflection_for

Methods included from Helpers::FileColumnDetection

#is_file?

Methods included from Helpers::ButtonsHelper

#buttons, #commit_button

Methods included from Helpers::InputsHelper

#inputs

Methods included from Helpers::InputHelper

#input

Instance Attribute Details

#auto_indexObject (readonly)

Returns the value of attribute auto_index.



34
35
36
# File 'lib/formtastic/form_builder.rb', line 34

def auto_index
  @auto_index
end

#templateObject (readonly)

Returns the value of attribute template.



32
33
34
# File 'lib/formtastic/form_builder.rb', line 32

def template
  @template
end

Class Method Details

.configure(name, value = nil) ⇒ Object



4
5
6
7
# File 'lib/formtastic/form_builder.rb', line 4

def self.configure(name, value = nil)
  class_attribute(name)
  self.send(:"#{name}=", value)
end

Instance Method Details

#semantic_fields_for(record_or_name_or_array, *args, &block) ⇒ Object

A thin wrapper around ‘ActionView::Helpers::FormBuilder#fields_for` helper to set `:builder => Formtastic::FormBuilder` for nesting forms inside the builder. Can be used in the same way, but you’ll also have access to the helpers in ‘Formtastic::FormBuilder` (such as Helpers::InputHelper#input, etc) inside the block.

Examples:

<% semantic_form_for @post do |post| %>
  <% post.semantic_fields_for :author do |author| %>
    <% author.inputs :name %>
  <% end %>
<% end %>

<form ...>
  <fieldset class="inputs">
    <ol>
      <li class="string"><input type='text' name='post[author][name]' id='post_author_name' /></li>
    </ol>
  </fieldset>
</form>

See Also:



66
67
68
69
70
71
# File 'lib/formtastic/form_builder.rb', line 66

def semantic_fields_for(record_or_name_or_array, *args, &block)
  opts = args.extract_options!
  opts[:builder] ||= self.class
  args.push(opts)
  fields_for(record_or_name_or_array, *args, &block)
end