Sha256: 56fdead669c032c7b543c42b568b3591f9fd95100dd586221b797941cbf7f4b7

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

module ActiveAdmin
  module Inputs
    module FilterBase
      include ::Formtastic::Inputs::Base

      def input_wrapping(&block)
        template.content_tag(:div,
          template.capture(&block),
          wrapper_html_options
        )
      end

      def required?
        false
      end

      def wrapper_html_options
        { :class => "filter_form_field #{as}" }
      end

      # Override the standard finder to accept a proc
      def collection_from_options
        if options[:collection].is_a?(Proc)
          options[:collection].call
        else
          super
        end
      end

      # Returns the default label for a given attribute
      # Will use ActiveModel I18n if possible
      def humanized_method_name
        if object.base.respond_to?(:human_attribute_name)
          object.base.human_attribute_name(method)
        else
          method.to_s.send(builder.label_str_method)
        end
      end

      # Returns the association reflection for the method if it exists
      def reflection_for(method)
        @object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
activeadmin-0.4.1 lib/active_admin/inputs/filter_base.rb
activeadmin-0.4.0 lib/active_admin/inputs/filter_base.rb
andrewroth_activeadmin-0.3.4.4 lib/active_admin/inputs/filter_base.rb
andrewroth_activeadmin-0.3.4.3 lib/active_admin/inputs/filter_base.rb
andrewroth_activeadmin-0.3.4.2 lib/active_admin/inputs/filter_base.rb
andrewroth_activeadmin-0.3.4.1 lib/active_admin/inputs/filter_base.rb