View Source Backpex.Filters.MultiSelect behaviour (Backpex v0.8.1)

The multi select filter renders checkboxes for a given list of options, hence allowing the user to select multiple values.

See the following example for an implementation of a multi select user filter.

defmodule MyAppWeb.Filters.MultiUserSelect do
  use Backpex.Filters.MultiSelect

  @impl Backpex.Filter
  def label, do: "User"

  @impl Backpex.Filters.MultiSelect
  def prompt, do: "Select user ..."

  @impl Backpex.Filters.MultiSelect
  def options, do: [
    {"John Doe", "acdd1860-65ce-4ed6-a37c-433851cf68d7"},
    {"Jane Doe", "9d78ce5e-9334-4a6c-a076-f1e72522de2"}
  ]
end

use Backpex.Filters.MultiSelect

When you use Backpex.Filters.MultiSelect, the Backpex.Filters.MultiSelect module will set @behavior Backpex.Filters.Select. In addition it will add a render and render_form function in order to display the corresponding filter.

Summary

Callbacks

The list of options for the multi select filter.

Functions

Attributes

  • value (:any) (required)
  • options (:list) (required)

Attributes

  • form (:any) (required)
  • field (:atom) (required)
  • value (:any) (required)
  • options (:list) (required)
  • prompt (:string) (required)

Callbacks

@callback options() :: [{String.t() | atom(), String.t() | atom()}]

The list of options for the multi select filter.

Functions

Link to this function

find_option_label(options, key)

View Source
Link to this function

maybe_query(predicates, query)

View Source
Link to this function

option_value_to_label(options, values)

View Source
Link to this function

query(query, attribute, value)

View Source

Attributes

  • value (:any) (required)
  • options (:list) (required)

Attributes

  • form (:any) (required)
  • field (:atom) (required)
  • value (:any) (required)
  • options (:list) (required)
  • prompt (:string) (required)