Sha256: 3f0ebf65540803291a5bc215d76a1b8d41dcaaeb1077c18191b9195a8962f206

Contents?: true

Size: 504 Bytes

Versions: 1

Compression:

Stored size: 504 Bytes

Contents

module ActiveEnum
  module FormHelpers
    class SimpleForm < SimpleForm::Inputs::CollectionInput

      def initialize(builder)
        super
        raise "Attribute '#{attribute_name}' has no enum class" unless enum = object.class.enum_for(attribute_name)
        builder.options[:collection] = enum.to_select
      end
      
    end
  end
end

SimpleForm::FormBuilder.class_eval do
  map_type :enum, :to => ActiveEnum::FormHelpers::SimpleForm
  alias_method :collection_enum, :collection_select
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_enum-0.7.0 lib/active_enum/form_helpers/simple_form.rb