© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•11mo ago•
1 reply
Shaung Bhone

Filament Select Field Option Display Issue

The issue I'm facing is that the Select field is showing the modified HTML option (from getCleanOptionString) in both the dropdown and the selected state. I want to show a different representation like only the product when the option is selected.
Forms\Components\Select::make('product_id')
    //
    ->allowHtml(true)
    ->options(
        Product::query()
            ->whereHas('stocks', function ($query) {
                $query->where('remaining_stock', '>', 0);
            })
            ->limit(10)
            ->orderBy('name')
            ->get()
            ->mapWithKeys(fn($product) => [
                $product->getKey() => static::getCleanOptionString($product)
            ])
            ->toArray()
    )
    ->getOptionLabelUsing(function ($value) {
     $product = Product::find($value);
     return $product ? $product->name : '';
})
Forms\Components\Select::make('product_id')
    //
    ->allowHtml(true)
    ->options(
        Product::query()
            ->whereHas('stocks', function ($query) {
                $query->where('remaining_stock', '>', 0);
            })
            ->limit(10)
            ->orderBy('name')
            ->get()
            ->mapWithKeys(fn($product) => [
                $product->getKey() => static::getCleanOptionString($product)
            ])
            ->toArray()
    )
    ->getOptionLabelUsing(function ($value) {
     $product = Product::find($value);
     return $product ? $product->name : '';
})
Screenshot_2568-04-09_at_22.16.25.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Filament Select Option
FilamentFFilament / ❓┊help
3y ago
Delete option inside select field
FilamentFFilament / ❓┊help
2y ago
Null option for Select Field
FilamentFFilament / ❓┊help
3y ago
Display category to select field
FilamentFFilament / ❓┊help
3y ago