module Enumerize::Hooks::SimpleFormBuilderExtension

Public Instance Methods

input_with_enumerize(attribute_name, options={}, &block) click to toggle source
# File lib/enumerize/hooks/simple_form.rb, line 12
def input_with_enumerize(attribute_name, options={}, &block)
  klass = object.class

  if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[attribute_name])
    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

  input_without_enumerize(attribute_name, options, &block)
end