Flash.md 921 B

Flash Component

An enhanced FlashComponent capable of

  • Stackable messages for each type
  • Persistent (across requests) and transient messages
  • Inject it into the headers as X-Ajax-Flashmessage for REST/AJAX requests

Configs

Usage

Attach it to your controllers in initialize() like so:

$this->loadComponent('Tools.Flash');

Also add the helper for it:

public $helpers = array('Tools.Flash');

In your layouts, you don't need to change the $this->Flash->render() call, as the syntax for this helper is the same.

Basic Example

// Inside an action
$this->Flash->message('Yeah it works.', 'success');
$this->Flash->message('Careful.', 'warning');
$this->Flash->message('O o.', 'error');

You can also use the new syntactic sugar:

// Inside an action
$this->Flash->success('Yeah it works.');
$this->Flash->warning('Careful.');
$this->Flash->error('O o.');