Module: Formtastic::Inputs::Base

Extended by:
ActiveSupport::Autoload
Includes:
Associations, Database, Errors, Fileish, Hints, Html, Labelling, Naming, Options, Validations, Wrapping
Included in:
BooleanInput, CheckBoxesInput, ColorInput, CountryInput, DatalistInput, DatePickerInput, DateSelectInput, DatetimePickerInput, DatetimeSelectInput, EmailInput, FileInput, HiddenInput, NumberInput, PasswordInput, PhoneInput, RadioInput, RangeInput, SearchInput, SelectInput, StringInput, TextInput, TimePickerInput, TimeSelectInput, 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/naming.rb,
lib/formtastic/inputs/base/errors.rb,
lib/formtastic/inputs/base/choices.rb,
lib/formtastic/inputs/base/fileish.rb,
lib/formtastic/inputs/base/timeish.rb,
lib/formtastic/inputs/base/options.rb,
lib/formtastic/inputs/base/numeric.rb,
lib/formtastic/inputs/base/wrapping.rb,
lib/formtastic/inputs/base/database.rb,
lib/formtastic/inputs/base/stringish.rb,
lib/formtastic/inputs/base/labelling.rb,
lib/formtastic/inputs/base/placeholder.rb,
lib/formtastic/inputs/base/validations.rb,
lib/formtastic/inputs/base/collections.rb,
lib/formtastic/inputs/base/associations.rb,
lib/formtastic/inputs/base/datetime_pickerish.rb

Defined Under Namespace

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Wrapping

#input_wrapping, #wrapper_classes, #wrapper_classes_raw, #wrapper_dom_id, #wrapper_html_options, #wrapper_html_options_raw

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 LocalizedString

#model_name

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

- (Object) builder

Returns the value of attribute builder



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

def builder
  @builder
end

- (Object) method

Returns the value of attribute method



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

def method
  @method
end

- (Object) object

Returns the value of attribute object



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

def object
  @object
end

- (Object) object_name

Returns the value of attribute object_name



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

def object_name
  @object_name
end

- (Object) options

Returns the value of attribute options



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

def options
  @options
end

- (Object) template

Returns the value of attribute template



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

def template
  @template
end

Instance Method Details

- (Object) initialize(builder, template, object, object_name, method, options)



7
8
9
10
11
12
13
14
# 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
end

- (Object) removed_option!(old_option_name)

Usefull for raising an error on previously supported option.

Raises:

  • (ArgumentError)


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

def removed_option!(old_option_name)
  raise ArgumentError, ":#{old_option_name} is no longer available" if options.key?(old_option_name)
end

- (Object) warn_and_correct_option!(old_option_name, new_option_name)

Usefull for deprecating options.



17
18
19
20
21
22
# File 'lib/formtastic/inputs/base.rb', line 17

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 in the next version")
    options[new_option_name] = options.delete(old_option_name)
  end
end

- (Object) warn_deprecated_option!(old_option_name, instructions)

Usefull for deprecating options.



25
26
27
28
29
# File 'lib/formtastic/inputs/base.rb', line 25

def warn_deprecated_option!(old_option_name, instructions)
  if options.key?(old_option_name)
    ::ActiveSupport::Deprecation.warn("The :#{old_option_name} option is deprecated in favour of `#{instructions}` and will be removed in the next version")
  end
end