F
Filamentβ€’2mo ago
Tjiel

How to change capitalization on model label?

Hey all a resource for my model QrCodes, in this model I have set the model label the following way:
public static function getModelLabel(): string
{
return __('QR access code');
}

public static function getPluralModelLabel(): string
{
return __('QR access codes');
}
public static function getModelLabel(): string
{
return __('QR access code');
}

public static function getPluralModelLabel(): string
{
return __('QR access codes');
}
The problem im having is that its displaying Qr Access Codes instead of QR access codes. According to the documentation you can prevent default the default capitalization in the following way:
protected static bool $hasTitleCaseModelLabel = false;
protected static bool $hasTitleCaseModelLabel = false;
https://filamentphp.com/docs/3.x/panels/resources/getting-started#automatic-model-label-capitalization But variable is not reconized and doesn't do anything. So my question is if anybody knows how I might solve this problem.
8 Replies
Tally
Tallyβ€’2mo ago
should work
public static function getModelLabel(): string
{
return 'QR access code';
}

public static function getPluralModelLabel(): string
{
return 'QR access codes';
}

protected static bool $hasTitleCaseModelLabel = false;
public static function getModelLabel(): string
{
return 'QR access code';
}

public static function getPluralModelLabel(): string
{
return 'QR access codes';
}

protected static bool $hasTitleCaseModelLabel = false;
output here is QR access codes maybe you have a translation in place? check if the string option works πŸ™‚
Tjiel
Tjielβ€’2mo ago
@Tally thanks for the response, i have tried it without the translation but that still doesn't work. I for some reason also doesn't light up the $hasTitleCaseModelLabel in my editor like it does with the $navigationIcon. See the attached screenshot for reference.
Tjiel
Tjielβ€’2mo ago
No description
Tally
Tallyβ€’2mo ago
you're using Filament v3?
Tjiel
Tjielβ€’2mo ago
This is the filament version in my composer.json
"filament/filament": "^3.0-stable",
"filament/filament": "^3.0-stable",
Tally
Tallyβ€’2mo ago
The function is intruduced in 3.1 somewhere... could you check shich version you're using? Or just upgrade to minimal 3.2 The hasTitleCaseModelLabel feature was introduced in Filament v3.2
Tjiel
Tjielβ€’2mo ago
That must be it, Il give an update whenever I have time to upgrade it to a higher version. Thanks for helping me out.
Tally
Tallyβ€’2mo ago
πŸ‘πŸ»