FlashHelper class to render flash messages.
After setting messages in your controllers with FlashComponent, you can use this class to output your flash messages in your views.
render( string $key 'flash' , array $options array() )
Used to render the message set in FlashComponent::set()
In your view: $this->Flash->render('somekey'); Will default to flash if no param is passed
You can pass additional information into the flash message generation. This allows you to consolidate all the parameters for a given type of flash message into the view.
echo $this->Flash->render('flash', array('params' => array('name' => $user['User']['name'])));
This would pass the current user's name into the flash message, so you could create personalized messages without the controller needing access to that data.
Lastly you can choose the element that is used for rendering the flash message. Using custom elements allows you to fully customize how flash messages are generated.
echo $this->Flash->render('flash', array('element' => 'my_custom_element'));
If you want to use an element from a plugin for rendering your flash message you can use the dot notation for the plugin's element name:
echo $this->Flash->render('flash', array( 'element' => 'MyPlugin.my_custom_element', ));
$key
optional 'flash' $options
optional array() Additional options to use for the creation of this flash message. Supports the 'params', and 'element' keys that are used in the helper.
Rendered flash message or null if flash key does not exist in session.
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-FlashHelper.html