Class: SimpleForm::Inputs::CollectionInput

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_form/inputs/collection_input.rb

Constant Summary collapse

BASIC_OBJECT_CLASSES =
[String, Integer, Float, NilClass, Symbol, TrueClass, FalseClass]

Instance Attribute Summary

Attributes inherited from Base

#attribute_name, #column, #html_classes, #input_html_classes, #input_html_options, #input_type, #options, #reflection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#additional_classes, disable, enable, #initialize, #input_class

Methods included from SimpleForm::I18nCache

#get_i18n_cache, #i18n_cache, #reset_i18n_cache

Methods included from Components::Readonly

#readonly

Methods included from Components::Placeholders

#placeholder, #placeholder_text

Methods included from Components::Pattern

#pattern

Methods included from Components::MinMax

#min_max

Methods included from Components::Minlength

#minlength

Methods included from Components::Maxlength

#maxlength

Methods included from Components::LabelInput

#label_input

Methods included from Components::HTML5

#html5, #html5?, #initialize, #input_html_aria_required_option, #input_html_required_option

Methods included from Components::Hints

#has_hint?, #hint

Methods included from Components::Errors

#error, #full_error, #has_errors?, #has_value?, #valid?

Methods included from Helpers::Validators

#has_validators?

Constructor Details

This class inherits a constructor from SimpleForm::Inputs::Base

Class Method Details

.boolean_collectionObject

Default boolean collection for use with selects/radios when no collection is given. Always fallback to this boolean collection. Texts can be translated using i18n in “simple_form.yes” and “simple_form.no” keys. See the example locale file.


12
13
14
15
16
17
# File 'lib/simple_form/inputs/collection_input.rb', line 12

def self.boolean_collection
  i18n_cache :boolean_collection do
    [ [I18n.t(:"simple_form.yes", default: 'Yes'), true],
      [I18n.t(:"simple_form.no", default: 'No'), false] ]
  end
end

Instance Method Details

#input(wrapper_options = nil) ⇒ Object

Raises:

  • (NotImplementedError)

19
20
21
22
# File 'lib/simple_form/inputs/collection_input.rb', line 19

def input(wrapper_options = nil)
  raise NotImplementedError,
    "input should be implemented by classes inheriting from CollectionInput"
end

#input_optionsObject


24
25
26
27
28
29
30
31
32
# File 'lib/simple_form/inputs/collection_input.rb', line 24

def input_options
  options = super

  options[:include_blank] = true unless skip_include_blank?
  translate_option options, :prompt
  translate_option options, :include_blank

  options
end