Sha256: c285ac051de89689c9c94ae1cb745d565ae7038ead20d210121aa54e6381de6a

Contents?: true

Size: 1.17 KB

Versions: 17

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  module Inputs
    module Filters
      class CheckBoxesInput < ::Formtastic::Inputs::CheckBoxesInput
        include Base

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

        def selected_values
          @object.public_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
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.2.4 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.2.3 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.2.2 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.2.1 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.2.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.1.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-3.0.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.14.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.13.1 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.13.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.12.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.11.2 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.11.1 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.11.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.10.1 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.10.0 lib/active_admin/inputs/filters/check_boxes_input.rb