Sha256: 3081a6cede3b672092919bd256351f71b3f50ba582f2c52c141aa6bcbfca70b0

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

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

4 entries across 4 versions & 2 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/inputs/filters/check_boxes_input.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.9.0 lib/active_admin/inputs/filters/check_boxes_input.rb
activeadmin-2.8.1 lib/active_admin/inputs/filters/check_boxes_input.rb