nickyfsh
nickyfsh

Reputation: 175

cakePHP Flash message append class not working

I am trying to get my head around the flash message functionality in cakePHP.

In my current script is use the following approach:

     $this->Session->setFlash('Error');

which as a result gives me the following output:

    <div id="flashMessage" class="message">Error</div>

However when I try to append a custom class to it:

    $this->Session->setFlash('Error', array ('class' => 'errormsg'));

the message / flash does not seem to be generated / is not visible in my sourcecode output at all.

Any ideas what can be wrong here?

Upvotes: 1

Views: 3440

Answers (3)

Gus
Gus

Reputation: 16017

For those using Cake 2.7+ (where SessionComponent::setFlash is deprecated), use

$this->Flash->set('Error', array('params' => array('class' => 'errormsg')));

Upvotes: 0

liyakat
liyakat

Reputation: 11853

As per cakephp session component you have to pass like below

$this->Session->setFlash('Error', 'default', array('class' => 'errormsg'));

you can take more reference from link

let me know if i can help you

Upvotes: 3

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

try changing:

$this->Session->setFlash('Error', array ('class' => 'errormsg'));

to

$this->Session->setFlash('Error', 'default', array ('class' => 'errormsg'));

See:: cakePHP setFlash

Upvotes: 7

Related Questions