Module: Enumerize::Hooks::FormtasticFormBuilderExtension

Defined in:
lib/enumerize/hooks/formtastic.rb

Instance Method Summary collapse

Instance Method Details

#input(method, options = {}) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/enumerize/hooks/formtastic.rb', line 9

def input(method, options={})
  enumerized_object = convert_to_model(object)
  klass = enumerized_object.class

  if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[method])
    options[:collection] ||= attr.options

    if attr.kind_of?(Enumerize::Multiple) && options[:as] != :check_boxes
      options[:input_html] = options.fetch(:input_html, {}).merge(:multiple => true)
    end
  end

  super(method, options)
end