F
Filament12mo ago
Hugo

Group filters

How can I group these two filters so as to display the label above, in the same way as a Fieldset ? Or something similar
Filter::make('age_range')
->label('Tranche d\'âge')
->form([
TextInput::make('age_from')
->label('Âge minimum')
->numeric(),
TextInput::make('age_until')
->label('Âge maximum')
->numeric(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['age_from'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '<=', now()->subYears($age)),
)
->when(
$data['age_until'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '>=', now()->subYears($age + 1)->addDay()),
);
}),
Filter::make('age_range')
->label('Tranche d\'âge')
->form([
TextInput::make('age_from')
->label('Âge minimum')
->numeric(),
TextInput::make('age_until')
->label('Âge maximum')
->numeric(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['age_from'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '<=', now()->subYears($age)),
)
->when(
$data['age_until'],
fn(Builder $query, $age): Builder => $query->whereDate('birth_date', '>=', now()->subYears($age + 1)->addDay()),
);
}),
Thanks
3 Replies
awcodes
awcodes12mo ago
Wrap your form inputs in a Fieldset
Hugo
HugoOP12mo ago
Thank you !
Want results from more Discord servers?
Add your server