getAllFlashes() public method
Returns all flash messages.
You may use this method to display all the flash messages in a view file:
<?php
foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
} ?>
With the above code you can use the bootstrap alert classes such as success, info, danger as the flash message key to influence the color of the div.
Note that if you use addFlash(), $message will be an array, and you will have to adjust the above code.
See also:
| public array getAllFlashes ( $delete = false ) | ||
|---|---|---|
| $delete | boolean |
Whether to delete the flash messages right after this method is called. If false, the flash messages will be automatically deleted in the next request. |
| return | array |
Flash messages (key => message or key => [message1, message2]). |
Please login to continue.