Cakephp - Show flash messages at different positions in the view page
When you call setFlash, you can provide a key value. For example,
$this->Session->setFlash('This message is for form 1.', 'default', array(), 'form1');
Then you can print the flash above each form. It will only show up if the specified key has a value.
<?php echo $this->Session->flash('form1') ?>
You can find more information here.
Scrappy Cocco
Actually fingerstache hashtag live-edge hell of selvage small batch salvia fixie. Williamsburg cray mumblecore kitsch. Leggings trust fund butcher squid, veniam culpa cliche enamel pin vape raw denim. Bicycle rights pork belly swag migas, 3 wolf moon consectetur church-key pinterest. Excepteur quinoa artisan, organic sint fixie tousled aesthetic nulla fanny pack shaman. Ut etsy palo santo retro hell of. Locavore disrupt crucifix vice magna consequat, cillum ethical.
Updated on June 05, 2022Comments
-
Scrappy Cocco almost 2 years
I have a view file which have two forms in it at different positions say,
one form is at the left corner and the other at the right corner.
once the form is submitted successfully , a success message is flashed using
$this->Session->setFlash();
Problem is if Form1 is triggered i want to show the message flash under Form1 ie on the left corner.
Or if Form2 is triggered i want to show the message flash under Form2 ie on the right corner.
But right now both the messages are displayed at the top because i have put in layout
<?php echo $this->Session->flash(); ?>
I want to change this but not know how to achieve this.... :'(
-
Scrappy Cocco about 11 yearsWoww....thats fantastic....this works like a charm....thankyou @Lawrence Barsanti
-
Scrappy Cocco about 11 yearssimply putting $this->Session->flash(); wont work we would need to provide a key value as Lawrence Barsanti says...