© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
jelmerkeij

Form builder: Select with getSearchResultsUsing() shows id on form load instead of name

I have a product with relation
bundledProducts
bundledProducts
that indicate the products the main product has as 'children'. Using the form builder I have a seleclist inside a repeater to be able to select these children.

The select gets it's options through a function via
getSearchResultsUsing()
getSearchResultsUsing()
:

->schema( [
  Forms\Components\Repeater::make( 'bundledProducts' )
  ->label( __( 'labels.product.plural' ) )
  ->schema( [
    Forms\Components\Select::make( 'bundled_product_id' )
      ->label( 'Product' )
      ->searchable()
      ->getSearchResultsUsing( fn( string $search ) => ProductHelper::searchProducts( $search, onlyProductTypes: [ ProductTypeEnum::DEFAULT->value ] ) )
      ->getOptionLabelFromRecordUsing( fn( ?Product $record ) => $record->name )
      ->inlineLabel()
      ->required(),
    ] )
] )
->schema( [
  Forms\Components\Repeater::make( 'bundledProducts' )
  ->label( __( 'labels.product.plural' ) )
  ->schema( [
    Forms\Components\Select::make( 'bundled_product_id' )
      ->label( 'Product' )
      ->searchable()
      ->getSearchResultsUsing( fn( string $search ) => ProductHelper::searchProducts( $search, onlyProductTypes: [ ProductTypeEnum::DEFAULT->value ] ) )
      ->getOptionLabelFromRecordUsing( fn( ?Product $record ) => $record->name )
      ->inlineLabel()
      ->required(),
    ] )
] )


Now
ProductHelper::searchProducts()
ProductHelper::searchProducts()
returns an array with the
product_id
product_id
as key and
name
name
as value. This works fine when searching for options.
But when loading the form the id's of the children are displayed instead of the name (in my example the product has children with id
2
2
and
4
4
). (please see attachment)

I can't figure out what I'm doing wrong here?
Screenshot_2023-06-15_at_12.16.56.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 Action: Select field shows ID instead of name when filling form
FilamentFFilament / ❓┊help
5mo ago
'name' gone in Select multiple() after getSearchResultsUsing()
FilamentFFilament / ❓┊help
3y ago
Select multiple getSearchResultsUsing()
FilamentFFilament / ❓┊help
3y ago