Module: ActiveAdmin::Inputs::FilterBase

Includes:
Formtastic::Inputs::Base
Included in:
FilterCheckBoxesInput, FilterDateRangeInput, FilterNumericInput, FilterSelectInput, FilterStringInput
Defined in:
lib/active_admin/inputs/filter_base.rb

Instance Method Summary collapse

Instance Method Details

#collection_from_optionsObject

Override the standard finder to accept a proc



22
23
24
25
26
27
28
# File 'lib/active_admin/inputs/filter_base.rb', line 22

def collection_from_options
  if options[:collection].is_a?(Proc)
    options[:collection].call
  else
    super
  end
end

#humanized_method_nameObject

Returns the default label for a given attribute Will use ActiveModel I18n if possible



32
33
34
35
36
37
38
# File 'lib/active_admin/inputs/filter_base.rb', line 32

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

#input_wrapping(&block) ⇒ Object



6
7
8
9
10
11
# File 'lib/active_admin/inputs/filter_base.rb', line 6

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

#reflection_for(method) ⇒ Object

Returns the association reflection for the method if it exists



41
42
43
# File 'lib/active_admin/inputs/filter_base.rb', line 41

def reflection_for(method)
  @object.base.reflect_on_association(method) if @object.base.respond_to?(:reflect_on_association)
end

#required?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/active_admin/inputs/filter_base.rb', line 13

def required?
  false
end

#wrapper_html_optionsObject



17
18
19
# File 'lib/active_admin/inputs/filter_base.rb', line 17

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