Flash Messages

The flash helper provides a way to pass temporary objects between actions. The instance of this class is available in the Session object: Phpr::$session->flash.

function flash_message()

Returns a message previously set by a page function. Flash messages are designed for passing messages from action to pages (partials and templates), for example for passing form validation errors. If you use standard POST method (not AJAX) for your forms, you need to place flash_message() function above a form to display error messages generated by a page action.

If flash message is not empty, it is wrapped into a paragraph element with class attribute “flash” + message type, for example \<p class=“flash error”\>\</p\>. Possible values for the message types are ‘error’ and ‘success’. If flash message is empty, the function returns nothing.


The following code outputs a flash message right after the FORM element is opened.

<?= open_form() ?>
<?= flash_message() ?>