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 Koch12mo ago
You cannot modify the argument name. It must be $record not $user:
->getOptionLabelFromRecordUsing(fn (User $record) => )
->getOptionLabelFromRecordUsing(fn (User $record) => )
Benjamin
Benjamin12mo ago
Oh yep, thanks a lot for your help !