Skip to content

Commit a9cbbc2

Browse files
[5.x] Terms Filter: Use terms fieldtype instead of select (#13439)
1 parent 55af5d6 commit a9cbbc2

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

src/Query/Scopes/Filters/Fields/Terms.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ public function fieldItems()
2020
'default' => 'like',
2121
],
2222
'term' => [
23-
'type' => 'select',
24-
'options' => $this->options()->all(),
23+
'type' => 'terms',
2524
'placeholder' => __('Term'),
2625
'clearable' => true,
26+
'mode' => 'select',
27+
'max_items' => 1,
28+
'taxonomies' => $this->fieldtype->taxonomies(),
2729
'if' => [
2830
'operator' => 'contains_any like',
2931
],
@@ -63,21 +65,4 @@ public function badge($values)
6365

6466
return $field.': '.$term;
6567
}
66-
67-
protected function options()
68-
{
69-
return collect($this->fieldtype->taxonomies())
70-
->map(function ($handle) {
71-
return Facades\Taxonomy::find($handle);
72-
})
73-
->filter()
74-
->flatMap(function ($taxonomy) {
75-
return $taxonomy->queryTerms()->get();
76-
})
77-
->mapWithKeys(function ($term) {
78-
$value = $this->fieldtype->usingSingleTaxonomy() ? $term->slug() : $term->id();
79-
80-
return [$value => $term->title()];
81-
});
82-
}
8368
}

0 commit comments

Comments
 (0)