© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
ngaiza_287

Get Relationship Value in Table Action from Form

Hello, Am trying to get a value of a relationship field in table action from action form. I cant seem to get it of $data array.


Action::make('add')
                ->label('Add Results')
                ->icon('heroicon-s-plus-circle')
                ->color('warning')
                ->form([
                    Select::make('exam_id')
                        ->label('Examination')
                        ->options(Exam::all()->pluck('name', 'id'))
                        ->required(),

                    Select::make('subject_id')
                        ->label('Subject')
                        ->relationship('subjects', 'name')
                        ->hint('Please select only one subject')
                        ->multiple()
                        ->required()
                        ->preload(),
                ])->action(function (Model $record, array $data): string {
                    $subject = $data['subject_id']; // I need to get this value
                    dd($subject);
                    return redirect()->route('results.record', [
                                                                'grade' => $record,
                                                                'exam' => $data['exam_id'],
                                                                'subject' => $data['subject_id']
                                                            ]);
                }),

Action::make('add')
                ->label('Add Results')
                ->icon('heroicon-s-plus-circle')
                ->color('warning')
                ->form([
                    Select::make('exam_id')
                        ->label('Examination')
                        ->options(Exam::all()->pluck('name', 'id'))
                        ->required(),

                    Select::make('subject_id')
                        ->label('Subject')
                        ->relationship('subjects', 'name')
                        ->hint('Please select only one subject')
                        ->multiple()
                        ->required()
                        ->preload(),
                ])->action(function (Model $record, array $data): string {
                    $subject = $data['subject_id']; // I need to get this value
                    dd($subject);
                    return redirect()->route('results.record', [
                                                                'grade' => $record,
                                                                'exam' => $data['exam_id'],
                                                                'subject' => $data['subject_id']
                                                            ]);
                }),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to get $data from table form action?
FilamentFFilament / ❓┊help
2y ago
get form data from action
FilamentFFilament / ❓┊help
3y ago
Get value from another Grid relationship
FilamentFFilament / ❓┊help
2y ago
Action that changes value in Form
FilamentFFilament / ❓┊help
3y ago