FlashMessages don't work after redirect
- josef.sabl
- Member | 153
Hey guys, I read through all the post about this topic but to no avail. My problem is flash messages don't show after redirect (They work well without redirecting).
I don't know where to look. The app is relatively clean sandbox nothing special.
My URL after redirect looks like this:
http://localhost:88/?_fid=sdz1
And bdump of session on target page is here.
I don't know where to look and what piece of code to post.
I generate flash messages as simply as this:
I am on 3.0 beta.
- Roman Halaxa
- Member | 60
Hi. Do you have code to draw them in you Homepage:index:default latte file ? ?
taken from docs
Make sure you have something like this in your template file of the page you're redirecting to
- josef.sabl
- Member | 153
Yes, sure, I have that code in my layout that is extended by action templates. Just to make sure the template is fine I tried this action:
and the flash message is rendered.
Roman Halaxa wrote:
Hi. Do you have code to draw them in you Homepage:index:default latte file ? ?
taken from docs
Make sure you have something like this in your template file of the page you're redirecting to
- David Grudl
- Nette Core | 8249
I think the best way is to step through the code and see why it does not pass session data to the template.
- josef.sabl
- Member | 153
Yeah, I love Xdebug, but in this case it is a bit problematic, with the nature of the flashmessages (session, redirects, 3 seconds expiration), but I'll try harder ;-)
- josef.sabl
- Member | 153
Looks like: \Nette\Application\UI\Component::getParameter
returns false ($this->params === []
) even if I can see the
parameters in the URL. Will try to look further into this.
- josef.sabl
- Member | 153
However when I bdump $this->getParameters in the action code. It contains the params. Looks like something is called in the wrong order.
- josef.sabl
- Member | 153
Hah, found it!
I had a presenter code like this:
… and changed it to:
Thanks @dg for extra motivation!!!
Btw, isn't there a way to register translator to template factory somehow? Or what is the best practice for setting the system-wide translator? I hate setting translator for presenter, email templates and maybe even form, separately.
Last edited by josef.sabl (2019-03-12 16:54)