Class: Motr::Forms::Base

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/motr/forms/base.rb

Overview

Base class for creating form builders

Direct Known Subclasses

Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_field_typeObject

Tracks the field currently being “processed”



16
17
18
# File 'lib/motr/forms/base.rb', line 16

def current_field_type
  @current_field_type
end

#field_orderObject

Tracks the order in which fields are used in the form, this allows the easy rebuilding of the submitted form data when submitted since normally the hash isn’t ordered.



14
15
16
# File 'lib/motr/forms/base.rb', line 14

def field_order
  @field_order
end

#templateObject

Access the template object



11
12
13
# File 'lib/motr/forms/base.rb', line 11

def template
  @template
end

Instance Method Details

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

Overrides fields_for to make sure the form builder is set properly



21
22
23
24
25
26
27
28
# File 'lib/motr/forms/base.rb', line 21

def fields_for(record_or_name_or_array, *args, &block) #:nodoc:
  opts = args.extract_options!
  opts[:builder] ||= Motr::Forms.default_builder
  args.push(opts)
  Motr::Forms.with_custom_error_proc do
    super(record_or_name_or_array, *args, &block)
  end
end