Sha256: 940f6bcc935577e1d49988553baab49cac4104569d9653fd6e8b666c13be9b41

Contents?: true

Size: 710 Bytes

Versions: 11

Compression:

Stored size: 710 Bytes

Contents

module ActiveEnum
  module FormHelpers
    module Formtastic
      def default_input_type_with_active_enum(method, options)
        return :enum if @object.class.respond_to?(:active_enum_for) && @object.class.active_enum_for(method)
        default_input_type_without_active_enum(method, options)
      end

      def enum_input(method, options)
        raise "Attribute '#{method}' has no enum class" unless enum = @object.class.active_enum_for(method)
        select_input(method, options.merge(:collection => enum.to_select))
      end

    end
  end
end

Formtastic::SemanticFormBuilder.class_eval do
  include ActiveEnum::FormHelpers::Formtastic
  alias_method_chain :default_input_type, :active_enum
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_enum-0.9.12 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.11 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.10 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.9 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.8 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.7 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.6 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.5 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.4 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.3 lib/active_enum/form_helpers/formtastic.rb
active_enum-0.9.1 lib/active_enum/form_helpers/formtastic.rb