Introduction
The select column allows you to render a select field inside the table, which can be used to update that database record without needing to open a new page or a modal. You must pass options to the column:Enabling the JavaScript select
By default, Filament uses the native HTML5 select. You may enable a more customizable JavaScript select using thenative(false) method:
As well as allowing a static value, the native() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
native() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Searching options
You may enable a search input to allow easier access to many options, using thesearchableOptions() method:
As well as allowing a static value, the searchableOptions() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
searchableOptions() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Returning custom search results
If you have lots of options and want to populate them based on a database search or other external data source, you can use thegetOptionsSearchResultsUsing() and getOptionLabelUsing() methods instead of options().
The getOptionsSearchResultsUsing() method accepts a callback that returns search results in $key => $value format. The current user’s search is available as $search, and you should use that to filter your results.
The getOptionLabelUsing() method accepts a callback that transforms the selected option $value into a label. This is used when the form is first loaded when the user has not made a search yet. Otherwise, the label used to display the currently selected option would not be available.
Both getOptionsSearchResultsUsing() and getOptionLabelUsing() must be used on the select if you want to provide custom search results:
getOptionLabelUsing() is crucial, since it provides Filament with the label of the selected option, so it doesn’t need to execute a full search to find it. If an option is not valid, it should return null.
You can inject various utilities into these functions as parameters.
Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
Search
$search
?string
[
getOptionsSearchResultsUsing() only] The current search input value, if the field is searchable.State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Option value
$value
mixed
The option value to retrieve the label for.
Setting a custom loading message
When you’re using a searchable select or multi-select, you may want to display a custom message while the options are loading. You can do this using theoptionsLoadingMessage() method:
As well as allowing a static value, the optionsLoadingMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
optionsLoadingMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Setting a custom no search results message
When you’re using a searchable select or multi-select, you may want to display a custom message when no search results are found. You can do this using thenoOptionsSearchResultsMessage() method:
As well as allowing a static value, the noOptionsSearchResultsMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
noOptionsSearchResultsMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Setting a custom search prompt
When you’re using a searchable select or multi-select, you may want to display a custom message when the user has not yet entered a search term. You can do this using theoptionsSearchPrompt() method:
As well as allowing a static value, the optionsSearchPrompt() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
optionsSearchPrompt() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Setting a custom searching message
When you’re using a searchable select or multi-select, you may want to display a custom message while the search results are being loaded. You can do this using theoptionsSearchingMessage() method:
As well as allowing a static value, the optionsSearchingMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
optionsSearchingMessage() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Tweaking the search debounce
By default, Filament will wait 1000 milliseconds (1 second) before searching for options when the user types in a searchable select or multi-select. It will also wait 1000 milliseconds between searches, if the user is continuously typing into the search input. You can change this using theoptionsSearchDebounce() method:
As well as allowing a static value, the optionsSearchDebounce() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
optionsSearchDebounce() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Integrating with an Eloquent relationship
You may employ theoptionsRelationship() method of the SelectColumn to configure a BelongsTo relationship to automatically retrieve options from. The titleAttribute is the name of a column that will be used to generate a label for each option:
Searching relationship options across multiple columns
By default, if the select is also searchable, Filament will return search results for the relationship based on the title column of the relationship. If you’d like to search across multiple columns, you can pass an array of columns to thesearchableOptions() method:
Preloading relationship options
If you’d like to populate the searchable options from the database when the page is loaded, instead of when the user searches, you can use thepreloadOptions() method:
As well as allowing a static value, the preload() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
preload() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Excluding the current record
When working with recursive relationships, you will likely want to remove the current record from the set of results. This can be easily be done using theignoreRecord argument:
Customizing the relationship query
You may customize the database query that retrieves options using the third parameter of theoptionsRelationship() method:
The modifyQueryUsing argument can inject various utilities into the function as parameters.
modifyQueryUsing argument can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Query
$query
Illuminate\Database\Eloquent\Builder
The Eloquent query builder to modify.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
Search
$search
?string
The current search input value, if the field is searchable.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Customizing the relationship option labels
If you’d like to customize the label of each option, maybe to be more descriptive, or to concatenate a first and last name, you could use a virtual column in your database migration:getOptionLabelFromRecordUsing() method to transform an option’s Eloquent model into a label:
The getOptionLabelFromRecordUsing() method can inject various utilities into the function as parameters.
getOptionLabelFromRecordUsing() method can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
Illuminate\Database\Eloquent\Model
The Eloquent record to get the option label for.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Remembering options
By default, when usingoptionsRelationship(), Filament will remember the options for the duration of the table page to improve performance. This means that the options function will only run once per table page instead of once per cell. You can disable this behavior using the rememberOptions(false) method:
As well as allowing a static value, the rememberOptions() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
rememberOptions() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Allowing HTML in the option labels
By default, Filament will escape any HTML in the option labels. If you’d like to allow HTML, you can use theallowOptionsHtml() method:
Be aware that you will need to ensure that the HTML is safe to render, otherwise your application will be vulnerable to XSS attacks.
As well as allowing a static value, the allowOptionsHtml() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
allowOptionsHtml() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Wrap or truncate option labels
When using the JavaScript select, labels that exceed the width of the select element will wrap onto multiple lines by default. Alternatively, you may choose to truncate overflowing labels.As well as allowing a static value, the wrapOptionLabels() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
wrapOptionLabels() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Disable placeholder selection
You can prevent the placeholder (null option) from being selected using theselectablePlaceholder(false) method:
As well as allowing a static value, the selectablePlaceholder() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
selectablePlaceholder() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Disabling specific options
You can disable specific options using thedisableOptionWhen() method. It accepts a closure, in which you can check if the option with a specific $value should be disabled:
You can inject various utilities into the function as parameters.
Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Option label
$label
string | Illuminate\Contracts\Support\Htmlable
The label of the option to disable.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Option value
$value
mixed
The value of the option to disable.
Limiting the number of options
You can limit the number of options that are displayed in a searchable select or multi-select using theoptionsLimit() method. The default is 50:
As well as allowing a static value, the optionsLimit() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
optionsLimit() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Column
$column
Filament\Tables\Columns\Column
The current column instance.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current table row.
Row loop
$rowLoop
stdClass
The row loop object for the current table row.
State
$state
mixed
The current value of the column, based on the current table row.
Table
$table
Filament\Tables\Table
The current table instance.
Validation
You can validate the input by passing any Laravel validation rules in an array:Valid options validation (in rule)
The in rule ensures that users cannot select an option that is not in the list of options. This is an important rule for data integrity purposes, so Filament applies it by default to all select fields.
Since there are many ways for a select field to populate its options, and in many cases the options are not all loaded into the select by default and require searching to retrieve them, Filament uses the presence of a valid “option label” to determine whether the selected value exists. It also checks if that option is disabled or not.
If you are using a custom search query to retrieve options, you should ensure that the getOptionLabelUsing() method is defined, so that Filament can validate the selected value against the available options:
getOptionLabelUsing() method should return null if the option is not valid, to allow Filament to determine that the selected value is not in the list of options. If the option is valid, it should return the label of the option.
If you are using the optionsRelationship() method, the getOptionLabelUsing() method will be automatically defined for you, so you don’t need to worry about it.