View Source Backpex.Filters.Range behaviour (Backpex v0.1.1)
Range filters render two input fields of the same type. Backpex offers the :date
, :datetime
and the number
type.
A basic implementation of a date range filter would look like this:
defmodule MyAppWeb.Filters.DateRange do
use Backpex.Filters.Range
@impl Backpex.Filters.Range
def type, do: :date
@impl Backpex.Filter
def label, do: "Date Range (begins at)"
end
Note that the query function is already implemented via
Backpex.Filters.Range
.
use Backpex.Filters.Range
When you
use Backpex.Filters.Range
, theBackpex.Filters.Range
module will set@behavior Backpex.Filters.Range
. In addition it will add arender
andrender_form
function in order to display the corresponding filter. It will also implement theBackpex.Filter.query
function to define a range query.
Summary
Callbacks
@callback type() :: :date | :datetime | :number
The type return value defines the rendered input fields of the range filter.