user456584
user456584

Reputation: 88845

ActiveAdmin: How to use multi-select in a filter?

A client wants to be able to filter records based on a set of objects from a one-to-one relationship (rather than just one at a time) in ActiveAdmin. I'm having trouble finding documentation regarding such functionality.

How can I present a basic multi-select filter option instead of the single-select used by default in ActiveAdmin?

Upvotes: 2

Views: 3627

Answers (1)

Sergio Belevskij
Sergio Belevskij

Reputation: 2947

It's very simple. Just add to your filter definition this option: multiple => true example:

filter(:categories, {
  as: :select,
  multiple: true,
  input_html: {
    class: :select2,
    style: "width: 100%;"
  },
  label: I18n.t(:categories)
})

Upvotes: 5

Related Questions