Dependent select searchable

I can't seem to make this work. The second selection doesn't seem to populate.

If I use the options ()instead of getSearchResultsUsing() and
getOptionLabelUsing() Without searchable(), the second selection populates but doesn't clear it. But I want both of the selects is searchable.

Select::make('drawer_id')
       ->searchable()

       // ->options(Drawer::query()->pluck('name', 'id'))
       // ->afterStateUpdated(fn (Set $set) => $set('folder_id', []))

       ->getSearchResultsUsing(fn (string $search): array => Drawer::query()->pluck('name', 'id')->toArray())
       ->getOptionLabelUsing(fn ($value): ?string => Drawer::find($value)?->name)

       ->reactive(),

Select::make('folder_id')
      >searchable()
      ->getSearchResultsUsing(fn (Get $get): array => Folder::where('drawer_id', $get('drawer_id'))->limit(50)->pluck('name', 'id')->toArray())
      ->getOptionLabelUsing(fn ($value): ?string => Drawer::find($value)?->name),
Was this page helpful?