Select filter - remove/disable default option
I want to display records for one option only. I default the select filter to the first option but there is an 'All' option in the select filter which would allow a user to view all records. Is there any way to remove the "All" option?
9 Replies
https://filamentphp.com/docs/2.x/tables/getting-started#pagination
getTableRecordsPerPageSelectOptions()
Filament
Getting started - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Sorry I'm not talking about pagination I'm talking about table filters. https://filamentphp.com/docs/2.x/tables/filters#select-filters
I would essentially like the functionality of radio buttons but they don't appear to be an option.
Filament
Filters - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Well you can make a custom filter using a select that doesn’t have an all option.
But all make sense as a way to clear the filter.
I’m confused as to what you are trying to accomplish. Does just the normal filter that renders as a checkbox not accomplish what you want?
What states do you want to have?
I mean ‘all’ in a filter isn’t showing all records for the model. Its not pagination. It’s just resetting the filter to the original query.
It sounds like OP just wants to have the records filtered by default? As I understand it, you have a select filter that has one option (let’s say “published) and you default to having it filter to “published” but it’s also showing “all” and you don’t want to allow your users to click “all”. That’s how I’m understanding the question. And if that’s the case you don’t need a filter at all. Just add a scope to your eloquent query. @max_prawn can you clarify?
Sorry, I guess I didn't explain it well. @kennethsese you are on the right track. Lets say my options in the select filter are published and unpublished. I would set the default to published and only published records would be displayed. I want the user to be able to filter by unpublished records but never both published and unpublished.
So in this case you'll have to do a custom filter like @awcodes said. The key is that when you do a custom filter and use a Select field you can disable the placeholder selection (something you can't do on Select Filters). So something like this:
Thanks for your replies. I'll give this a go.