F
Filament11mo ago
bionary

Filters applied on load?

using Filament v.2 I have a table widget with some filters. I have a "less then pricing" filter for input pricing. When the page/table loads the filter is being applied automatically with a value == 0. How do I prevent table widget filters from being applied on load? (with filament v.2) Relevant code:
Filter::make('max_price')
->form([
TextInput::make('max_price_input')->label('Maximum price')
])->columns(2)
->query(fn (Builder $query, $data): Builder => $query
->where('price', '<=', (int)$data['max_price_input'])
)
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['max_price_input'] ?? null) {
$indicators['max_price_input'] = 'Max price = $' . number_format($data['max_price_input'], 0);
}
return $indicators;
})
Filter::make('max_price')
->form([
TextInput::make('max_price_input')->label('Maximum price')
])->columns(2)
->query(fn (Builder $query, $data): Builder => $query
->where('price', '<=', (int)$data['max_price_input'])
)
->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['max_price_input'] ?? null) {
$indicators['max_price_input'] = 'Max price = $' . number_format($data['max_price_input'], 0);
}
return $indicators;
})
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server