© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•5mo ago•
5 replies
Adrian A

Filament Action: Select field shows ID instead of name when filling form

Hi everyone,

I have a Filament Action that opens a form with a Select field for choosing an instructor.

The issue is:
When the action is opened, the instructor select field shows the instructor’s ID instead of their name.

Here’s the situation:

My fillForm() method sets the value using the instructor’s id.

The select displays the raw id in the input, not the instructor name.

If I change fillForm() to use the instructor name, it shows correctly, but then I get a validation or saving error saying it “only accepts IDs.”

What’s the correct way to make the select field display the instructor’s name but still store the ID when submitting?

Action::make('Edit Section')
  ->modalWidth('md')
  ->fillForm(fn(Section $record) => [
        'name' => $record->name,
        'instructor_id' => $record->instructor_id,
        'course_id' => $record->course_
])
  ->schema([
  Select::make('instructor_id')
         ->label('Instructor')
         ->relationship(
              'instructor',
              modifyQueryUsing: fn($query) => $query->whereInstructorDepartment(auth()->user()->instructor-        >department_id))
          ->getOptionLabelFromRecordUsing(fn($record) => $record->full_name)
          ->searchable()
          ->preload()
          ->required(),
  Select::make('course_id')
      ->label('Course')
      ->options(
          fn() => Course::whereDepartment(auth()->user()->instructor->department_id)
              ->pluck('code', 'id')
              ->toArray()
      )
       ->searchable()
        ->preload()
        ->required(),
])
      ->action(function (array $data, Section $record) {
          $record->update($data);
          Notification::make()
->title('Section updated successfully')
->success()
->send();
})
Action::make('Edit Section')
  ->modalWidth('md')
  ->fillForm(fn(Section $record) => [
        'name' => $record->name,
        'instructor_id' => $record->instructor_id,
        'course_id' => $record->course_
])
  ->schema([
  Select::make('instructor_id')
         ->label('Instructor')
         ->relationship(
              'instructor',
              modifyQueryUsing: fn($query) => $query->whereInstructorDepartment(auth()->user()->instructor-        >department_id))
          ->getOptionLabelFromRecordUsing(fn($record) => $record->full_name)
          ->searchable()
          ->preload()
          ->required(),
  Select::make('course_id')
      ->label('Course')
      ->options(
          fn() => Course::whereDepartment(auth()->user()->instructor->department_id)
              ->pluck('code', 'id')
              ->toArray()
      )
       ->searchable()
        ->preload()
        ->required(),
])
      ->action(function (array $data, Section $record) {
          $record->update($data);
          Notification::make()
->title('Section updated successfully')
->success()
->send();
})
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

Form builder: Select with getSearchResultsUsing() shows id on form load instead of name
FilamentFFilament / ❓┊help
3y ago
Show name instead of id in Select relationship field, upon record soft deletion.
FilamentFFilament / ❓┊help
2y ago
Filament Action: Select field value missing from $data when using multiple()
FilamentFFilament / ❓┊help
5mo ago
Filament Select Form Component
FilamentFFilament / ❓┊help
2y ago