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:
Solution:Jump to 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 it9 Replies
I think you can customize it using
getTitle()
Unfortunately, it doesn't work. it's the same as this property which doesn't change the model label:
hum.. this was supposed to work
Is it even possible in ManageRelatedRecords? Or there isn't such an option to change the model label at all?
using title I guess
What do you mean by ‘manage relations page’?
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
I think in this particular case you will need to extend the create action directly. https://filamentphp.com/docs/3.x/panels/resources/relation-managers#customizing-the-createaction
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