Module: Formtastic::Inputs::Base

Extended by:
ActiveSupport::Autoload
Includes:
Associations, Database, Errors, Fileish, Hints, Html, Labelling, Naming, Options, Validations, Wrapping
Included in:
BooleanInput, CheckBoxesInput, CountryInput, DateInput, DatetimeInput, EmailInput, FileInput, HiddenInput, NumberInput, PasswordInput, PhoneInput, RadioInput, RangeInput, SearchInput, SelectInput, StringInput, TextInput, TimeInput, TimeZoneInput, UrlInput
Defined in:
lib/formtastic/inputs/base.rb,
lib/formtastic/inputs/base/html.rb,
lib/formtastic/inputs/base/hints.rb,
lib/formtastic/inputs/base/errors.rb,
lib/formtastic/inputs/base/naming.rb,
lib/formtastic/inputs/base/choices.rb,
lib/formtastic/inputs/base/fileish.rb,
lib/formtastic/inputs/base/options.rb,
lib/formtastic/inputs/base/timeish.rb,
lib/formtastic/inputs/base/database.rb,
lib/formtastic/inputs/base/wrapping.rb,
lib/formtastic/inputs/base/labelling.rb,
lib/formtastic/inputs/base/stringish.rb,
lib/formtastic/inputs/base/collections.rb,
lib/formtastic/inputs/base/validations.rb,
lib/formtastic/inputs/base/associations.rb,
lib/formtastic/inputs/base/grouped_collections.rb

Defined Under Namespace

Modules: Associations, Choices, Collections, Database, Errors, Fileish, GroupedCollections, Hints, Html, Labelling, Naming, Options, Stringish, Timeish, Validations, Wrapping

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Wrapping

#input_wrapping, #wrapper_dom_id, #wrapper_html_options

Methods included from Labelling

#label_from_options, #label_html, #label_html_options, #label_text, #localized_label, #render_label?, #requirement_text, #requirement_text_or_proc

Methods included from Associations

#association, #association_primary_key, #belongs_to?, #has_many?, #reflection

Methods included from Fileish

#file?

Methods included from Validations

#autofocus?, #column_limit, #limit, #not_required_through_negated_validation!, #not_required_through_negated_validation?, #optional?, #required?, #required_attribute?, #responds_to_global_required?, #validation_integer_only?, #validation_limit, #validation_max, #validation_min, #validation_step, #validations, #validations?, #validator_relevant?

Methods included from Naming

#as, #attributized_method_name, #humanized_method_name, #input_name, #sanitized_method_name, #sanitized_object_name

Methods included from Hints

#hint?, #hint_html, #hint_text, #hint_text_from_options

Methods included from Errors

#error_first_html, #error_html, #error_keys, #error_list_html, #error_none_html, #error_sentence_html, #errors, #errors?

Methods included from Database

#column, #column?

Methods included from Options

#formtastic_options, #input_options

Methods included from Html

#dom_id, #dom_index, #input_html_options, #to_html

Instance Attribute Details

#builderObject

Returns the value of attribute builder.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def builder
  @builder
end

#methodObject

Returns the value of attribute method.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def method
  @method
end

#objectObject

Returns the value of attribute object.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def object
  @object
end

#object_nameObject

Returns the value of attribute object_name.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def object_name
  @object_name
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def options
  @options
end

#templateObject

Returns the value of attribute template.



5
6
7
# File 'lib/formtastic/inputs/base.rb', line 5

def template
  @template
end

Instance Method Details

#initialize(builder, template, object, object_name, method, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/formtastic/inputs/base.rb', line 7

def initialize(builder, template, object, object_name, method, options)
  @builder = builder
  @template = template
  @object = object
  @object_name = object_name
  @method = method
  @options = options.dup
  
  warn_and_correct_option!(:label_method, :member_label)
  warn_and_correct_option!(:value_method, :member_value)
  warn_and_correct_option!(:group_label_method, :group_label)
end

#warn_and_correct_option!(old_option_name, new_option_name) ⇒ Object



20
21
22
23
24
25
# File 'lib/formtastic/inputs/base.rb', line 20

def warn_and_correct_option!(old_option_name, new_option_name)
  if options.key?(old_option_name)
    ::ActiveSupport::Deprecation.warn("The :#{old_option_name} option is deprecated in favour of :#{new_option_name} and will be removed from Formtastic after 2.0")
    options[new_option_name] = options.delete(old_option_name)
  end
end