I have to be missing something here, just trying to set a flash message in a new project.
In controller:
$this->addFlash(
'success',
'Your entry was added!'
);
In my template, I include:
{% for message in app.flashes(['success', 'notice']) %}
<div class="alert alert-success">
<p align="center">
<b>Success! </b><br/>
{{ message }}
</p>
</div>
{% endfor %}
I get the following exception every time:
"An exception has been thrown during the rendering of a template ("Notice: Array to string conversion")."
I checked the length of message and it's zero. If I dump it, it's an empty array as it should be. Anyone see what I'm missing here, driving me crazy. Also, if I set a flash message it gives me the same error.
Read and display several types of flash messages:
{% for label, messages in app.flashes(['success', 'notice']) %}
{% for message in messages %}
<div class="alert alert-success">
<p align="center">
<b>Success! </b><br/>
{{ message }}
</p>
</div>
{% endfor %}
{% endfor %}
See: https://symfony.com/doc/current/controller.html#managing-the-session