Class: GenericFormFor::Inputs::SelectInput

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/generic_form_for/inputs/select_input.rb

Instance Attribute Summary

Attributes included from Base

#builder, #column, #method, #object, #object_name, #options, #template

Instance Method Summary collapse

Methods included from Base

#autofocus?, #default_input_options, #form_builder_options, #initialize, #input_html_class, #merge_html_options, #to_html, #wrap_in

Methods included from Base::ErrorMessage

#error_html, #error_html_options, #errors, #errors?, #render_error?

Methods included from Base::Label

#label_html, #label_html_options, #label_text, #render_label?, #requirement_text, #translated_label

Methods included from Base::Validations

#decimals, #limit, #limits_from_validations, #maximal_number, #minimal_number, #required?, #required_from_validations?

Methods included from Base::Hint

#hint_html, #hint_html_options, #hint_text, #render_hint?

Methods included from GenericFormFor::I18n

#translate, #translate_action, #translate_hint, #translate_label, #translate_legend, #translate_placeholder

Instance Method Details

#collectionObject



26
27
28
# File 'lib/generic_form_for/inputs/select_input.rb', line 26

def collection
  options[:collection]
end

#input_html(config_options = {}) ⇒ Object



10
11
12
# File 'lib/generic_form_for/inputs/select_input.rb', line 10

def input_html(config_options={})
  template.concat builder.select(method, collection, input_options, merge_html_options(input_html_options,config_options))
end

#input_html_optionsObject



6
7
8
# File 'lib/generic_form_for/inputs/select_input.rb', line 6

def input_html_options
  super.except(*[:include_blank, :selected, :value, :prompt])
end

#input_optionsObject



14
15
16
# File 'lib/generic_form_for/inputs/select_input.rb', line 14

def input_options
  {:selected => selected}.merge(super)
end

#selectedObject



18
19
20
21
22
23
24
# File 'lib/generic_form_for/inputs/select_input.rb', line 18

def selected
  if options.key?(:value) 
    return options[:value]
  end
  return false unless object.respond_to?(method)
  object.send(method)
end