Sha256: 50a8d021009602dff94c801fc3069561d54423e7b8757ace2226580245f6e638

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module ActiveAdmin
  module Inputs
    class FilterCheckBoxesInput < ::Formtastic::Inputs::CheckBoxesInput
      include FilterBase

      def input_name
        "#{object_name}[#{searchable_method_name}_in][]"
      end

      def selected_values
        @object.send("#{searchable_method_name}_in") || []
      end

      def searchable_method_name
        if searchable_has_many_through?
          "#{reflection.through_reflection.name}_#{reflection.foreign_key}"
        else
          association_primary_key || method
        end
      end

      # Add whitespace before label
      def choice_label(choice)
        ' ' + super
      end

      # Don't wrap in UL tag
      def choices_group_wrapping(&block)
        template.capture(&block)
      end

      # Don't wrap in LI tag
      def choice_wrapping(html_options, &block)
        template.capture(&block)
      end

      # Don't render hidden fields
      def hidden_field_for_all
        ""
      end

      # Don't render hidden fields
      def hidden_fields?
        false
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
active_administration-0.0.3 lib/active_admin/inputs/filter_check_boxes_input.rb
activeadministration-0.0.2 lib/active_admin/inputs/filter_check_boxes_input.rb
active_administration-0.0.2 lib/active_admin/inputs/filter_check_boxes_input.rb
activeadministration-0.0.1 lib/active_admin/inputs/filter_check_boxes_input.rb
active_administration-0.0.1 lib/active_admin/inputs/filter_check_boxes_input.rb