1

I have VPS where I run php (7.4) and nginx.

I have installed Nette and other packages by composer.

My problem is:

I can't print flash messages. In my presenter I have code $this->flashMessage("Odhlášení proběhlo úspěšně.", "success");

And in @layout.latte I have this:

{snippet flashes}
    {foreach $flashes as $flash}
        {if $flash->type === 'success'}
            <script>toastr.success({$flash->message});</script>
        {elseif $flash->type === 'info'}
            <script>toastr.info({$flash->message});</script>
        {elseif $flash->type === 'warning'}
            <script>toastr.warning({$flash->message});</script>
        {elseif $flash->type === 'error'}
            <script>toastr.error({$flash->message});</script>
        {else}
            <script>toastr.info({$flash->message});</script>
        {/if}
    {/foreach}
{/snippet}

When I dump $flashes in latte nothing is there.

EDIT:

Flashes save to session but latte can't take it from session.

EDIT 2:

I setting flash message by this way:

In processing form:

$this->flashMessage("Obrázek úspěšně upraven.", "success");
$this->redirect("Gallery:default");

What I have to do to fix this? Thanks for answers.

Marty1452
  • 430
  • 5
  • 19
  • You wrote that flashes are not being read from session. If you save something else into session, can you read it back on next request? Do flashes work for you when you don't redirect the user? – Petr 'PePa' Pavel May 24 '21 at 13:58

1 Answers1

0

I have this in @layout.latte and it works. Show the code of presenter where the flashMassage() is.

{snippet flashes}
  <div n:foreach="$flashes as $flash" class="flash {$flash->type}">
    {$flash->message}
  </div>
{/snippet}