Customize Record Title

Hi, in ContractResource i have:
protected static ?string $recordTitleAttribute = 'id';
protected static ?string $recordTitleAttribute = 'id';
How can I customize the title so that I can see "View Contract No. [id]" or "Edit Contract No. [4]" ?
7 Replies
Marco Mapelli
Marco MapelliOP15mo ago
It doesn’t work. I always have "View [id]" Filament v2
Thijmen
Thijmen15mo ago
On the EditPage do this:
protected function getTitle(): string
{
if (filled(static::$title)) {
return static::$title;
}

return 'View Contract No. ' . $this->getRecordTitle() . '';
}
protected function getTitle(): string
{
if (filled(static::$title)) {
return static::$title;
}

return 'View Contract No. ' . $this->getRecordTitle() . '';
}
christmex
christmex15mo ago
Hey, sorry, little correction in filament3 we use public not protected, if im not wrong, but @Marco Mapelli u can try this one, it works, but if you found any issue about the protected try to change it to public 🙂 https://filamentphp.com/docs/3.x/panels/upgrade-guide#method-signature-changes
Marco Mapelli
Marco MapelliOP15mo ago
Perfect !! Thanks
Thijmen
Thijmen15mo ago
Yeah i noticed he had V2 tag and this code is V2
christmex
christmex15mo ago
Oh yess, sorry, i just saw it, silly me, im sorry man
Want results from more Discord servers?
Add your server