cakePHP have by default FlashComponent which provides notification messages to be displayed in the website or application after processing a form .
FlashComponent in cakePHP writes flash messages to be rendered in a ctp file in view folder .
Setting Flash Messages
FlashComponent provides two ways to set flash messages: its call magic method and its set() method.
We use the set() method to use flash message handler.
the syntax for showing the flash messages is- >
$this->Flash->set('This is a message');
We can create our custom Flash elements too. , FlashComponent call magic method allows you use a method name that maps to an element located under the app/View/Elements/Flash directory.
// Uses app/View/Elements/Flash/one.ctp
$this->Flash->one('This was good');
// Uses app/View/Elements/Flash/two.ctp
$this->Flash->two('This was very good');
0 Comment(s)