Return to v2.5.0 docs

flashMessages()


View Helpers Miscellaneous Functions string controller


Displays a marked-up listing of messages that exist in the Flash.

Name Type Required Default Description
keys string No The key (or list of keys) to show the value for. You can also use the key argument instead for better readability when accessing a single key.
class string No flash-messages HTML class to set on the div element that contains the messages.
includeEmptyContainer boolean No false Includes the div container even if the Flash is empty.
encode boolean No true Use this argument to decide whether the output of the function should be encoded in order to prevent Cross Site Scripting (XSS) attacks. Set it to true to encode all relevant output for the specific HTML element in question (e.g. tag content, attribute values, and URLs). For HTML elements that have both tag content and attribute values you can set this argument to attributes to only encode attribute values and not tag content.
// In the controller action
flashInsert(success="Your post was successfully submitted.");
flashInsert(alert="Don't forget to tweet about this post!");
flashInsert(error="This is an error message.");

<!--- In the layout or view --->
#flashMessages()#

<!--- Generates this (sorted alphabetically):--->
<div class="flashMessages">
	<p class="alertMessage">
		Don't forget to tweet about this post!
	</p>
	<p class="errorMessage">
		This is an error message.
	</p>
	<p class="successMessage">
		Your post was successfully submitted.
	</p>
</div>


<!---  Only show the "success" key in the view --->
#flashMessages(key="success")#

<!--- Generates this: --->
<div class="flashMessage">
	<p class="successMessage">
		Your post was successfully submitted.
	</p>
</div>


<!--- Show only the "success" and "alert" keys in the view, in that order --->
#flashMessages(keys="success,alert")#

<!--- Generates this (sorted alphabetically):--->
<div class="flashMessages">
	<p class="successMessage">
		Your post was successfully submitted.
	</p>
	<p class="alertMessage">
		Don't forget to tweet about this post!
	</p>
</div>

Related Functions

Miscellaneous Functions