F
Filamentβ€’17mo ago
Benjamin

Select field : problem with getOptionLabelFromRecordUsing()

Hi ! I'm trying to customize my labels for a Select relationship field but it doesn't work.
// UsersResource.php (Filament Ressource)
Forms\Components\Select::make('interview_by')
->relationship('interviewBy', 'firstname')
->getOptionLabelFromRecordUsing(fn (User $user) => $user->getNickename())
// UsersResource.php (Filament Ressource)
Forms\Components\Select::make('interview_by')
->relationship('interviewBy', 'firstname')
->getOptionLabelFromRecordUsing(fn (User $user) => $user->getNickename())
// User.php (Model)
public function getNickename(): string
{
return "{$this->firstname} {$this->lastname}";
}
// User.php (Model)
public function getNickename(): string
{
return "{$this->firstname} {$this->lastname}";
}
And the result is blank πŸ€”
Solution:
You cannot modify the argument name. It must be $record not $user:
->getOptionLabelFromRecordUsing(fn (User $record) => )
->getOptionLabelFromRecordUsing(fn (User $record) => )
...
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Kochβ€’17mo ago
You cannot modify the argument name. It must be $record not $user:
->getOptionLabelFromRecordUsing(fn (User $record) => )
->getOptionLabelFromRecordUsing(fn (User $record) => )
Benjamin
BenjaminOPβ€’17mo ago
Oh yep, thanks a lot for your help !
Want results from more Discord servers?
Add your server