FilamentF
Filament14mo ago
Djomla

Table Filter Custom Option Html

Hi all,

In my resource $table, I want to have custom html in one of my select filters.

            ->filters([
                Tables\Filters\SelectFilter::make('sport_id')
                    ->options(function () {
                        $sports = Sport::all();

                        return $sports->mapWithKeys(function ($sport) {
                            $imageUrl = url('/storage/' . $sport->image);
                            $optionLabel = "<span class='filter-option'>
                                <img src='{$imageUrl}' alt='{$sport->name}' class='sport-icon'>
                                {$sport->name}
                            </span>";
                            return [$sport->id => $optionLabel];
                        })->toArray();
                    })
                    ->searchable()
                    ->label('Sport'),


But Im getting raw HTML as result.
image.png
Solution
GitHub
Description
The SelectFilter didn&#39;t support the -&gt;allowHtml() method, even though the Select:: form component does. This PR fixes that issue.
Visual changes


Functional changes

Co...
Was this page helpful?