Force refresh on page actions
I have an action on the edit page that changes some data on the model, and after that I want to conditionally hide that action and show another one (think publish/unpublish), but even though the form itself seems to refresh, the actions don't. Is there an event I could dispatch to force that?
7 Replies
Are you looking for this? https://filamentphp.com/docs/3.x/panels/pages#refreshing-form-data
it was supposed to work. Are you doing something like this?
exactly, although the action is in a method in the page component, but that shouldnt make a difference
I have a similar requirement on a relation manager page, so I have this on the relation manager ...
... and do this in the action ...
You can probably do the same with the listener on the EditFoo page. And (I think) use dispatch() instead of emit() in v3?
Thanks for the suggestions, but there doesnt seem to be an event that re-renders the header actions. I tried
cacheHeaderActions()
which just adds them to the header since they get added to the existing array of cached actions. Calling render()
also diesnt help. What's weird is, if I click the action a second time, it just works and the header actions get refreshed. Could have sworn this just worked in v2.
Doing this works. Not pretty, but well ...
I'll dig up how I was doing this and double check it. I had the exact same problem, that I needed the header action to hide and a different one show.
Let me know if you find a nicer way. The only other possibility I can think of is to redirect to current url after the action. But for now I'll keep this solution as it works.