FilamentPHP: Allow HTML in Select (Option) Label

In FilamentPHP, you can enable HTML in select option labels by customizing the field's rendering logic to display formatted text or icons, enhancing the user interface.

FilamentPHP: Allow HTML in Select (Option) Label

June 20, 2024

By default, FilamentPHP escapes HTML in select option labels, but enabling HTML rendering is necessary for scenarios like listing category nodes.

 

To enable HTML in select option labels, add the following code to your Select component:

    ->native(false)
    ->allowHtml()

so your component should look like this:

Select::make('category_id')
    ->native(false)
    ->allowHtml()
    ->options([...])