9 Replies
Just pass the formatted value via
getSearchResultsUsing()
Select::make('revenue_district_office_id')
->label('Revenue District Office')
->searchable()
->getSearchResultsUsing(fn (string $search): array => RevenueDistrictOffice::query()
->where('code', 'like', "%{$search}%")
->orWhere('location', 'like', "%{$search}%")
->limit(10)
->pluck(DB::raw("CONCAT(code, ' - ', location)"), 'id')
->all())
->required()
->preload(),
why is it preload isn't working?
please don't tag @Eskie as per #✅┊rules .
preload doesn't work with searchable since it's searching on typing
Sorry.. thank you!
Preload is working if i am not using getsearchresultusing even if the select is searchable..
Interesting, I assumed preload only loads (options or relationships) not search results snce you are not yet searching..

this is one of my selects but if i will use getSearchResultsUsing.. preload doesn't work
What if you do:
I'd also be tempted to relationship the options too.
I guess you are trying to format the option labels?
Maybe try
->getOptionLabelFromRecordUsing(fn ($record) => "{$record->code} - {$record->location}")