Overview

Checkbox List
Watch the Rapid Laravel Development with Filament series on Laracasts - it will teach you the basics of adding checkbox list fields to Filament forms.array cast to the model property:
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 theallowHtml() method:
Setting option descriptions
You can optionally provide descriptions to each option using thedescriptions() method. This method accepts an array of plain text strings, or instances of Illuminate\Support\HtmlString or Illuminate\Contracts\Support\Htmlable. This allows you to render HTML, or even markdown, in the descriptions:
key in the descriptions array as the key in the option array so the right description matches the right option.
Splitting options into columns
You may split options into columns by using thecolumns() method:
columns() method of the grid. This allows you to responsively customize the number of columns at various breakpoints.
Setting the grid direction
By default, when you arrange checkboxes into columns, they will be listed in order vertically. If you’d like to list them horizontally, you may use thegridDirection('row') method:
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:
getEnabledOptions():
Searching options
You may enable a search input to allow easier access to many options, using thesearchable() method:
Bulk toggling checkboxes
You may allow users to toggle all checkboxes at once using thebulkToggleable() method:
Integrating with an Eloquent relationship
If you’re building a form inside your Livewire component, make sure you have set up the form’s model. Otherwise, Filament doesn’t know which model to use to retrieve the relationship from.You may employ the
relationship() method of the CheckboxList to point to a BelongsToMany relationship. Filament will load the options from the relationship, and save them back to the relationship’s pivot table when the form is submitted. The titleAttribute is the name of a column that will be used to generate a label for each option:
disabled() with relationship(), ensure that disabled() is called before relationship(). This ensures that the dehydrated() call from within relationship() is not overridden by the call from disabled():
Customizing the relationship query
You may customize the database query that retrieves options using themodifyOptionsQueryUsing parameter of the relationship() method:
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:
Saving pivot data to the relationship
If your pivot table has additional columns, you can use thepivotData() method to specify the data that should be saved in them:
Setting a custom no search results message
When you’re using a searchable checkbox list, you may want to display a custom message when no search results are found. You can do this using thenoSearchResultsMessage() method:
Setting a custom search prompt
When you’re using a searchable checkbox list, you may want to tweak the search input’s placeholder when the user has not yet entered a search term. You can do this using thesearchPrompt() method:
Tweaking the search debounce
By default, Filament will wait 1000 milliseconds (1 second) before searching for options when the user types in a searchable checkbox list. It will also wait 1000 milliseconds between searches if the user is continuously typing into the search input. You can change this using thesearchDebounce() method:
Customizing the checkbox list action objects
This field uses action objects for easy customization of buttons within it. You can customize these buttons by passing a function to an action registration method. The function has access to the$action object, which you can use to customize it. The following methods are available to customize the actions:
selectAllAction()deselectAllAction()