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 : '';
})
No description
1 Reply
Shaung Bhone
Shaung BhoneOP2w ago
hi

Did you find this page helpful?