RFC 0083 — A filter by a related record: the customers picked by searching
Status: implemented (2026-11-30) · Target: 0.66.0 · builds on RFC 0069, RFC 0071 and RFC 0082 · see Decisions
Summary
"Invoices for Acme and Globex" is the filter a list of invoices is used
with most. RFC 0069's filters take text, numbers, dates and options; a
belongs_to column has none, because 3,000 customers aren't options.
RFC 0082 gave such a column a ref, which knows how to search them and
name them. This RFC lets the column filter by it.
{
key: "customer_id",
label: "Customer",
ref: { search: (s) => api.customers_index({ search: s, per_page: 20 }), find: (id) => api.customers_show(id) },
filter: "ref",
}
- The panel: a search for the records, each pick added to a list of the ones chosen, each with a way to take it out. Apply filters by them.
- The chip says them by name: "Customer: Acme Ltd, Globex".
query.filters.customer_idis the keys,[1, 2], as an options filter's values are: a plain array filters itself, a command and Laravel'selyraListtake it asoptions(whereIn), unchanged.- Saved views (RFC 0070) keep the keys; their names come back by
find. make:resourcegives a parent with a resourcefilter: "ref", and the command's filters aVecof its keys.
Motivation
- The most used filter isn't there. A list of invoices is filtered by customer, tasks by project, orders by supplier. Today that's the search box, which also matches the text in every other column.
- The pieces exist. The filters' panel, chips,
query.filtersand views (RFCs 0069, 0070); options filtered bywhereInin the command (filter_options) and inelyraList(options); andref's search and names (RFC 0082).
Current state (0.67)
- A column's
filteris"text","range","dates",{ options }or"options". Its panel setsquery.filters[key]; an options filter's value is a list of the options' values, and its chip their labels. - A command's
{Model}FiltershasOption<Vec<T>>for an options filter, applied withfilter_options(IN);elyraList'soptionskind iswhereIn. make:resourcegives a field a filter by its kind; a reference has none.- A
refcolumn (RFC 0082) shows names, found once a key, and searches its records withsearch.
Design
filter: "ref"
On a column with a ref. Its funnel opens the panel:
- A search: a
Comboboxoverref.search. A pick adds the record to the list below it, and empties the search for the next. - The chosen: each by its name, with a button to take it out
(
removeFilterValue(name), "Remove Acme Ltd"). - Apply sets
query.filters[key]to their keys, in the order picked; Clear takes the filter off, as for every filter. - The chip: "Customer: Acme Ltd, Globex"; past three, "Customer: Acme Ltd and 3 more".
What it filters
- A plain array keeps the rows whose key is one of them, as an options filter does.
- A live page's command gets
filters: { customer_id: [1, 2] }: the same shape as an options filter, sofilter_optionsandelyraList'soptionsapply it as they are. - No match is the list's empty state, as for any filter.
Names
The panel and the chip use the table's names (RFC 0082). A view or a
query that comes with keys the table hasn't named yet finds them with
find, and shows the keys until then.
make:resource
- A reference whose parent has a resource gets
filter: "ref"with itsref(RFC 0082), and is one the user may group by, as every filtered column is (RFC 0074). - The command's
{Model}FiltersgetsOption<Vec<{key type}>>for it, applied withfilter_options; with--backend, the controller'selyraListgets it as'options'.
Words
addFilterValue, removeFilterValue(name), chipMore(first, n), in
words.js and en/nb.
Implementation plan
ui/src/internal/filters.js: therefkind (its rows, its emptiness, its chip from names).Table.svelte: the panel's search and chosen list, the chip by names, keys from a view named byfind.- Words.
rata make:resource:filter: "ref", the filters'Vec, the controller's'options'; tests and the smoke.- Tests: the panel's pick, take out, apply and clear; the chip by name and past three; a plain array filtered; a live page's query; a view's keys named; the generated command filtering by keys.
- Docs:
table.md(filters), the skill,resources.md, CHANGELOG.
Open questions
- More than one record, or one? Recommendation: more than one, as an options filter is. "Acme and Globex" is a common ask, and one is the same with a list of one.
- The panel's list as checkboxes of recent picks? Recommendation: no. The chosen are listed with a way to take each out; recent picks are what a saved view is for.
- "Has none" (
customer_idempty)? Recommendation: not in this RFC. It's a different filter (IS NULL) for the command andelyraList, and few lists need it.
Decisions
Accepted 2026-11-30, with the open questions' recommendations:
- More than one record, as an options filter has.
- No list of recent picks: the chosen are listed, each with a way out; recent picks are a saved view's.
- No "has none" filter in this RFC.
As built
As designed, with these differences:
- The panel's search re-opens empty after each pick, for the next; Enter picking from its list doesn't apply the filter, only Apply or Enter with the list closed does.
make:resource's filter is for a parent with a resource: one without stays unfiltered, as it has no search. The command's filter isOption<Vec<key>>withfilter_options, the controller's hint'options', and the column is one the user may group by.- The chip's "and 2 more" is
chipMore(first, n), with the first three names.
Not in this RFC
- A filter for rows with no related record.
- Filtering by a related record's own fields ("customers in Oslo").
- Many-to-many (
belongs_to_many) filters.
Alternatives considered
- An options filter with every record. Fine for five teams, not for 3,000 customers, and the options would go stale.
- The search box. It finds "Acme" in every column, and can't say "these two".