Sha256: 9a755ac9f1f3f7874ede29a89642140ebc9f552c3127fb79bdfe79173dd7ef1f

Contents?: true

Size: 1.17 KB

Versions: 53

Compression:

Stored size: 1.17 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)
          template.instance_eval(&options[:collection])
        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

53 entries across 53 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/lib/active_admin/inputs/filter_base.rb