LemonStand Documentation

flash_message

function flash_message()

Returns a message previously set by a page action. 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.

If the flash_partial variable is presented in the POST array, the function renders a partial instead of returning the message string. Please read the LemonStand front-end JavaScript framework article to learn about the flash_partial feature.

Parameters

This function has no parameters.

Return value

Returns string.

Examples

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

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

Next: format_currency
Previous: customer_logout
Return to Reference