Class: SimpleForm::Inputs::CollectionInput

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

Direct Known Subclasses

PriorityInput

Constant Summary

Constants inherited from Base

Base::ACTIONS

Instance Attribute Summary

Attributes inherited from Base

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #input_html_classes, #render

Methods included from SimpleForm::I18nCache

#get_i18n_cache, #i18n_cache, #reset_i18n_cache

Methods included from Components::Wrapper

#wrap, #wrapper_class, #wrapper_error_class, #wrapper_html_options, #wrapper_tag

Methods included from Components::Placeholders

#has_placeholder?, #placeholder, #placeholder_present?, #placeholder_text

Methods included from Components::LabelInput

included, #label_input

Methods included from Components::Hints

#hint, #hint_html_options, #hint_tag, #hint_text

Methods included from Components::Errors

#error, #error_html_options, #error_method, #error_tag, #error_text

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.



8
9
10
11
12
13
# File 'lib/simple_form/inputs/collection_input.rb', line 8

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

#inputObject



15
16
17
18
19
20
# File 'lib/simple_form/inputs/collection_input.rb', line 15

def input
  label_method, value_method = detect_collection_methods

  @builder.send(:"collection_#{input_type}", attribute_name, collection,
                value_method, label_method, input_options, input_html_options)
end

#input_optionsObject



22
23
24
25
26
# File 'lib/simple_form/inputs/collection_input.rb', line 22

def input_options
  options = super
  options[:include_blank] = true unless skip_include_blank?
  options
end