© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
bwurtz999

Issue With Searchable Select

Hey All - I have a dynamically created schema as shown below:
->schema(function ($record) {
  $class = new EditEvent;
  $orderSchema = [];
  foreach ($record->orders as $order) {
    $orderSchema[] = $class->getEditForm($order)[0];
  }

  return $orderSchema;
})
->schema(function ($record) {
  $class = new EditEvent;
  $orderSchema = [];
  foreach ($record->orders as $order) {
    $orderSchema[] = $class->getEditForm($order)[0];
  }

  return $orderSchema;
})


Each event can have multiple orders, and each order has many selections. So instead of using a relation manager to make selections, I am dynamically generate this schema using the
->getEditForm()
->getEditForm()
function and displaying it directly on the
EditEvent
EditEvent
form.

I'm running into an issue with using
searchable()
searchable()
. When I use searchable, all of the menu options are shown based on the first order. But when
searchable()
searchable()
is not used, the menu options are displayed correctly based on the
order
order
that is passed to the function.

// this works correctly displaying the meals based on the order
Select::make('meal')
  ->label('Menu Option')
  // ->searchable()
  ->options(function() use ($order) {
    Log::debug($order->id);
    $meals =  Meal::where([
      ['kitchen_id', $order->provider_id],
      ['approved', true],
    ])->get();
    $returnArray = [];
    foreach($meals as $meal) {
      $returnArray[$meal->id] = $meal->name . ' - $' . number_format($meal->price, 2, '.', ',');
    }
    return $returnArray;
  })

// this does not work correctly
// it always uses the first order to pull the meals
Select::make('meal')
  ->label('Menu Option')
  ->searchable()
  ->options(function() use ($order) {
    Log::debug($order->id);
    $meals =  Meal::where([
      ['kitchen_id', $order->provider_id],
      ['approved', true],
    ])->get();
    $returnArray = [];
    foreach($meals as $meal) {
      $returnArray[$meal->id] = $meal->name . ' - $' . number_format($meal->price, 2, '.', ',');
    }
    return $returnArray;
  })
// this works correctly displaying the meals based on the order
Select::make('meal')
  ->label('Menu Option')
  // ->searchable()
  ->options(function() use ($order) {
    Log::debug($order->id);
    $meals =  Meal::where([
      ['kitchen_id', $order->provider_id],
      ['approved', true],
    ])->get();
    $returnArray = [];
    foreach($meals as $meal) {
      $returnArray[$meal->id] = $meal->name . ' - $' . number_format($meal->price, 2, '.', ',');
    }
    return $returnArray;
  })

// this does not work correctly
// it always uses the first order to pull the meals
Select::make('meal')
  ->label('Menu Option')
  ->searchable()
  ->options(function() use ($order) {
    Log::debug($order->id);
    $meals =  Meal::where([
      ['kitchen_id', $order->provider_id],
      ['approved', true],
    ])->get();
    $returnArray = [];
    foreach($meals as $meal) {
      $returnArray[$meal->id] = $meal->name . ' - $' . number_format($meal->price, 2, '.', ',');
    }
    return $returnArray;
  })


Does anyone have any ideas about what might be going on here? Thank you!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Select searchable
FilamentFFilament / ❓┊help
2y ago
Select with live() and searchable()
FilamentFFilament / ❓┊help
16mo ago
Select component with searchable & live?
FilamentFFilament / ❓┊help
3y ago
Problem with Reactive Searchable Select
FilamentFFilament / ❓┊help
3y ago