F
Filamentβ€’12mo ago
Laurens

Cannot use accessor for record title in global search

According to the docs (https://filamentphp.com/docs/3.x/panels/resources/getting-started#record-titles) I should be able to use accessors as the record title in global search. When I try this however I still get exceptions that the given title does not exist on the MySql table. This is the code I'm using currently. Using fullName has the same result.
// App\Filament\Resources\UserResource.php

protected static ?string $recordTitleAttribute = 'full_name';
// App\Filament\Resources\UserResource.php

protected static ?string $recordTitleAttribute = 'full_name';
// App\Models\User.php

public function fullName(): Attribute
{
return new Attribute(fn () => trim("$this->first_name $this->last_name"));
}
// App\Models\User.php

public function fullName(): Attribute
{
return new Attribute(fn () => trim("$this->first_name $this->last_name"));
}
What could be going on here? This is happening on Filament v3.1.1 and still after bumping to the .10 release. Thanks in advance!
2 Replies
toeknee
toekneeβ€’12mo ago
Wouldnt' that be: protected static ?string $recordTitleAttribute = 'fullName'; I don't think accessors restructure like classes do they?
Laurens
LaurensOPβ€’12mo ago
I've tried so πŸ™‚
This is the code I'm using currently. Using fullName has the same result.
This is the code I'm using currently. Using fullName has the same result.
So for now I've went with a virtual column instead as a workaround
Want results from more Discord servers?
Add your server