Notifications works when triggered on mount() but not when triggered on submit()?
Hi! I'm stuck on showing notifications in the panel builder. I'm trying to show a notification to the user to inform them that no results are found for their search query. Using the following approach on a custom page:
The notification is never shown but when I uncomment the
dd()
this is executed as expected. The weird thing is that the notifications seem to work fine on the mount()
function. The following snippets shows a notification when re-loading the page:
Thanks in advance!14 Replies
Have you ever posted this issue before?
I did, but couldn’t find an answer and I’m unable to find the old question within this channel.
Can you share the project on github?
Unfortunately it’s a corporate project and I’m unable to share the whole project. I can provide required code snippets though.
maybe you can share the custom page.. the whole code
The issue occurs on all pages, also the default resource ones. I made a new custom page that reproduces the error. But once again, it seems the issue is globally.
Is there something in the AppServiceProvider? Are you using plugins as well?
This is the appPanelProvider
this app/Providers/AppServiceProvider.php
This is a bit of a complex file were we decide if the provider we need is the admin or any of our other applications with something like this:
Then the AdminServiceProvider registers the appPanelProvider
probably an issue in your project, not Filament. Maybe you can duplicate the project, remove all resources, infos, etc, and share with us on github
I tried, but unfortunately the codebase is too complex to separate en share publicly. I did find some more info. When rendering a page the session has some attributes (as shown in the debugbar) but when I submit a form the session seems to be emptied?
I don’t know if I understood your question correctly, but wouldn’t it be easier to make a form with an action?
You would add an action that queries the DB for the $state and if no results are found it triggers a notification? Else it passes the collections to the results?
The question is independent of how the forms works. It's a general issue with displaying notifications. For an unknown reason they are displayed as expected before the mount(), but afterwards not.
I finally managed to fix this. Long story short: We defined custom middleware groups to completely separate between our admin panel and other application. Due to this change the
web
middleware was still empty. The notifications issue was solved by adding \Illuminate\Session\Middleware\StartSession::class
to the empty web
array.