Can't change $modelLabel in ManageRelatedRecords

I've created a relation page using ManageRelatedRecords but when I try to change the model label as I do in resources or normal relation managers it doesn't work. It seems there isn't such a property in ManageRelatedRecords to override and change the model label. How can I do it now? Here are the properties I've overridden:
protected static string $resource = PostResource::class;
protected static string $relationship = 'comments';
protected static ?string $navigationIcon = 'heroicon-o-chat-bubble-left-ellipsis';
protected static ?string $title = 'مدیریت کامنت های پست';
protected static ?string $navigationLabel = 'مدیریت کامنت ‌ها';
protected static ?string $breadcrumb = 'کامنت ‌ها';
protected static string $resource = PostResource::class;
protected static string $relationship = 'comments';
protected static ?string $navigationIcon = 'heroicon-o-chat-bubble-left-ellipsis';
protected static ?string $title = 'مدیریت کامنت های پست';
protected static ?string $navigationLabel = 'مدیریت کامنت ‌ها';
protected static ?string $breadcrumb = 'کامنت ‌ها';
Solution:
I could finally find the solution! I just had to use ->modelLabel() method in table function on $table and then pass the model label to it
Jump to solution
9 Replies
LeandroFerreira
LeandroFerreira6mo ago
I think you can customize it using getTitle()
public function getTitle(): string|Htmlable
{
return 'new title';
}
public function getTitle(): string|Htmlable
{
return 'new title';
}
Atena.D
Atena.DOP6mo ago
Unfortunately, it doesn't work. it's the same as this property which doesn't change the model label:
protected static ?string $title = '';
protected static ?string $title = '';
LeandroFerreira
LeandroFerreira6mo ago
hum.. this was supposed to work
Atena.D
Atena.DOP6mo ago
Is it even possible in ManageRelatedRecords? Or there isn't such an option to change the model label at all?
LeandroFerreira
LeandroFerreira6mo ago
using title I guess
awcodes
awcodes6mo ago
What do you mean by ‘manage relations page’?
Atena.D
Atena.DOP6mo ago
if you take a look at filament demo project in post resource, when you click on a post you'll view that post and there is a navigation tab at the top for managing post comments. My project is just like that with the same logic. But there is something I want to change. When you navigate to that manage post comments tab you'll see the list of comments and a button to create a new comment which its label is based on the comments model name and as far as I tried I couldn't change that. Like when creating a new resource we can change $modelLabel property value though in this case I cant change the modal label and there seems to be no property like $modelLabel in a relation page that extends ManageRelatedRecords
Solution
Atena.D
Atena.D6mo ago
I could finally find the solution! I just had to use ->modelLabel() method in table function on $table and then pass the model label to it
Want results from more Discord servers?
Add your server