Filament Relation Manager - Form Not Updating
Hi, I have a Filament Relation Manager and it's working well for the table part, but the form isn't updating in the browser. For example, the form function is as below:
However, this isn't reflected in the browser. Can someone offer some insight to why? I'm guessing the form may be being defined elsewhere instead but I have no idea where to start looking.
31 Replies
Have you tried to refresh the browser again after updating the data ?
Yeah, tried migrate:fresh and cache:clear too
The modal looks like this:
So I can attach users, but as you can see the name isn't showing and the additional test field is missing too, so I'm wondering where the actual displayed form is being defined if not in the relation manager.
I tried a dd() in the form before the return too, and it didn't run so makes it look like it's not getting to the Form function in the relation manager
Can you share the file here ? Easy for debugging
Let me know if you need other files
So I've found out how to do it with the ->form() function
But that's not how I want / would expect to have to do it
Sorry, when I say I can do it through the form() method, I can get the extra field etc but the relationship bit isn't working
Feel like I'm quite close but oh so far
Can you show the model ?
I'm getting a much different error now:
If you using a many to many . Probably you can change ->form(function (AttachAction $action) {
dd(print_r($this->mustReadUsers(), true));
return [
Forms\Components\Select::make('user_id')
->label('User')
->relationship('mustReadUsers', 'name')
->multiple()
->preload()
->searchable(),
];
}),
]) to ->authorize(true) only because attachfunction will take the record through mustReadUser relationship . You can try this first
This change sets it back to before, where the form function isn't being reached and just get a standard form like this:
Relationships all work great in Tinker
So the models must be fine. I think I'm missing something in my RelationManager
Probably that my table is not named in the standard convention? But I think I've done that properly at least as far as I can tell
Your model so far is good
But may i know . What form do you want to do ? Because . If you just want to attach the record . Thats how to do it
Else
You can try add $action->getRecordSelect()
I suppose the issue is then it's showing 'user' in list of users when attaching
Instead of the actually name
Can you explain why you're overriding the entire form()?
maybe i missed it, its a long thread
Hi Dan, I was overriding the form to try and figure out why it's showing 'user' instead of 'Mr User' in the above modal
Sorry, it has gotten a little long winded as I've gone round in circles with this, but I think I just need to figure out how to tell it I want the user's name in the select box rather than 'user'
please remove that override, that select will be using the "record title attribute" from the relation manager which is not defined
Solution
try
$table->recordTitleAttribute('name')
Think I've got it
Yes
Yeah, that has worked - so simple when you know where to look!
Agreed with dan
I missed it tol
that should be in the default relation manager stub so not sure why its not there for you
Too
the reason why its showing "user" is because we generate a default title from the model name if you dont have a record title attribute defined
I may have deleted it not knowing what it was doing, so probably my mistake
That's awesome, appreciate your support on this and helping me get there.