F
Filamentβ€’6mo 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β€’6mo 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
TjielOPβ€’6mo 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
TjielOPβ€’6mo ago
No description
Tally
Tallyβ€’6mo ago
you're using Filament v3?
Tjiel
TjielOPβ€’6mo ago
This is the filament version in my composer.json
"filament/filament": "^3.0-stable",
"filament/filament": "^3.0-stable",
Tally
Tallyβ€’6mo 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
TjielOPβ€’6mo 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β€’6mo ago
πŸ‘πŸ»
Want results from more Discord servers?
Add your server