FilamentF
Filament10mo ago
Crispy

Way to only allow numeric in search dropdown for filament select element?

Hello!

I have this select for Zipcode that populates after the user types inside the searchable() search options dropdown.

To enhance my accessibility for a screen reader, I want to disable non-numbers, so that we don't run into as many issues. Is there a way to do this? I'd love any tips on how to modify/validate the search field on a select.

Here's my code:
 Select::make('zip_code_id')
     ->searchable(fn)
     ->native(false)
     ->getSearchResultsUsing(fn ($livewire, string $search) => $livewire->agency->approved_zip_codes()
        ->where('zip_codes.code', 'like', "%{$search}%")
        ->limit(20)
        ->pluck('zip_codes.code', 'county_zip_code.zip_code_id')
        ->toArray()
     )
     ->required()
     ->label('Zip/Postal Code of the Request')
     ->validationAttribute('zip/postal code')
     ->reactive()
...
Screenshot_2025-03-20_at_1.47.34_PM.png
Screenshot_2025-03-20_at_1.47.52_PM.png
Was this page helpful?