Filament Action: Select field value missing from $data when using multiple()

Hi everyone, I’m running into an issue with a Filament Action form. I have a Select field inside the action. When the Select is set to multiple, the selected values do not appear in the $data array after submitting. However, if I remove ->multiple(), the value is included in $data as expected. The TextInput fields in the same form work fine and their values are present in $data. Here’s what I mean: With ->multiple() enabled: $data does not contain the select field. Without ->multiple(): the value is included correctly in $data. I dumped the $data after submission and here’s the result (screenshot attached): this is the code:
Action::make('AddStudent')
->form([
Select::make('student_id')
->label('Select Student')
->relationship(
name: 'students',
titleAttribute: 'name',
modifyQueryUsing: fn($query) => $query->where('role', 'student')
)
->searchable()
->preload()
->multiple()
->required(),
TextInput::make('enrolled_at')
->required()
])
->action(function (array $data) {
dd($data);
})
Action::make('AddStudent')
->form([
Select::make('student_id')
->label('Select Student')
->relationship(
name: 'students',
titleAttribute: 'name',
modifyQueryUsing: fn($query) => $query->where('role', 'student')
)
->searchable()
->preload()
->multiple()
->required(),
TextInput::make('enrolled_at')
->required()
])
->action(function (array $data) {
dd($data);
})
My question: What am I missing? Is there something special I need to configure for Select::make()->multiple() so that its data is included in $data? Thanks in advance!
No description
Solution:
the relationship function is the culprit, I think they handle the saving elsewhere, try removing it and add some hardcoded options and they should appear in the dd
Jump to solution
2 Replies
Solution
Bruno Pereira
Bruno Pereira17h ago
the relationship function is the culprit, I think they handle the saving elsewhere, try removing it and add some hardcoded options and they should appear in the dd
Adrian A
Adrian AOP17h ago
thanks man now it shows
No description

Did you find this page helpful?