Select not showing label, showing id instead

I have the following code:
Forms\Components\Select::make('category_id')
->label(__('labels.category'))
->getOptionLabelsUsing(fn(array $values): array => PetCategory::whereIn('id', $values)->pluck('name', 'id')->toArray())
->getSearchResultsUsing(fn(string $search): array => PetCategory::where('name->' . app()->getLocale(), 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray())
->searchable()
->required(),
Forms\Components\Select::make('category_id')
->label(__('labels.category'))
->getOptionLabelsUsing(fn(array $values): array => PetCategory::whereIn('id', $values)->pluck('name', 'id')->toArray())
->getSearchResultsUsing(fn(string $search): array => PetCategory::where('name->' . app()->getLocale(), 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray())
->searchable()
->required(),
The problem is that it's showing the id on the view/edit page and not the label: https://gyazo.com/d1163b57deb172be4ee8b3f4734ae762 How can i solve this? (The relationship method doesn't work becouse i use a translated related resource)
Gyazo
Gyazo
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server