FilamentF
Filament8mo ago
Joe C

Search modified select field

Hello,

I have the following Select field, saving to the database as JSON:

Select::make('customisations.MainMenu')
    ->hiddenLabel()
    ->allowHtml()
    ->reactive()
    ->preload()
    ->searchable()
    ->options(function (Get $get) {
        $moduleId = $get('module_id');

          return EnvironmentPreset::whereHas('environmentBase.modules', function                       ($query) use ($moduleId) {
                  $query->where('modules_environment_bases.module_id', $moduleId)
                      ->where('modules_environment_bases.section', 'Menu');
              })
              ->orderBy('environment_base_id')
              ->get()
              ->mapWithKeys(fn ($envPreset) => [
                  $envPreset->id => view('filament.forms.select.environment-select')->with([
                      'environment' => $envPreset,
                  ])->render(),
              ])
            ->toArray();
    })
    ->required(),


When searching the results are unpredictable. Is it using $envPreset->id for the value of each option? Although searching for that ID does not filter the list correctly. Appreciate any help!
Was this page helpful?