Refetch RelationManager data on parent resource save
Is there a way to refetch the query data for a relationmanager when the parent resource data is saved?
Currently I just reload the page after I finished saving.
I was wondering if there are any alternatives.
10 Replies
I got it. I just dispatch an event to the relationmanager from parent resource. This reloads the relationmanager table.
Code on Parent Resource:
Code on RelationManager:
Hi @Hemith, I found your message because I need do the same. Could you give more details to achieve that?
Where do you added the dispatch function? On the afterSave function from the Edit Page ?
Hi @gon.exe . Yes, I added it at the EditPage in the beforeSave() function.
Hi, thank you so much for your replay
I added it on afterSave() function from the EditPage
and then I added a refresh function on my Relation Manager Page:
but I get: "Method App\Filament\Resources\AssetResource\Pages\EditAsset::dispatch does not exist."
hmm that's odd. You are on filament v3, correct?
also, could you try running it inside the beforeSave() function?
I am running v2. I already tested the beforeSave function
ohh maybe that's the case. I'm running filamentv3 with livewire3.
Thanks, I'll figure out a little more!
I got it ! Thanks so much for your help! @Hemith
ciao, i'm trying to update a relationmanager after an infolist action
my action open a modal with a select, i can change the value of this select and correctly save in the db
but if i want to view the new relation, i need to refresh the page.
i'm using filament v3
in my edit resource i have addedd
in my relation manager
i've put a dd('test')
but it never fired
solved
GitHub
Reload Relation Manager after an Action · filamentphp filament · Di...
How can I make a relation manager reload after an action has completed on an edit or view page?