Options Format
I want to format the way my options are shown , I used getOptionLabelFromRecordUsing() but it is only working in single select but it doesnot work with multiple(). What can I use in multiple select to format my options label ?
->getOptionLabelsUsing ?
->relationship()? getOptionLabelFromRecordUsing() is working with me with relationship()->getOptionLabelsUsing->relationship()getOptionLabelFromRecordUsing()relationship() Forms\Components\Select::make('products')
->options(Product::where('active', true)->publicDisplay()->pluck('sku', 'id'))
->getOptionLabelUsing(fn (Model $record) => "{$record->name} | {$record->sku}")
->multiple()
->reactive()
->required()
->afterStateUpdated(function ($livewire, $state) {
$livewire->dispatch('productAdded', $state);
}),Forms\Components\Select::make('products')
->options(Product::where('active', true)
->publicDisplay()
->get()
->mapWithKeys(fn ($product) =>
[$product->id => "{$product->name} | {$product->sku}"]
)
->toArray()
)
->getOptionLabelsUsing(fn (array $values): array =>
Product::whereIn('id', $values)
->get()
->mapWithKeys(fn ($product) =>
[$product->id => "{$product->name} | {$product->sku}"]
)
->toArray()
)
->multiple()
->reactive()
->required()
->afterStateUpdated(function ($livewire, $state) {
$livewire->dispatch('productAdded', $state);
}),