CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.9 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.9
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper
  • None

Classes

  • CacheHelper
  • FlashHelper
  • FormHelper
  • HtmlHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • MootoolsEngineHelper
  • NumberHelper
  • PaginatorHelper
  • PrototypeEngineHelper
  • RssHelper
  • SessionHelper
  • TextHelper
  • TimeHelper

Class FlashHelper

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.

AppHelper
Extended by FlashHelper
Package: Cake\View\Helper
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/View/Helper/FlashHelper.php

Method Summary

  • render() public
    Used to render the message set in FlashComponent::set()

Method Detail

render() public ΒΆ

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',
));
Parameters
string $key optional 'flash'
The [Message.]key you are rendering in the view.
array $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.

Returns
string|null

Rendered flash message or null if flash key does not exist in session.


Throws
UnexpectedValueException
If value for flash settings key is not an array.
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs