CakePHP default flash doesn't always render

I'm experiencing an issue in CakePHP 2.0 whereby my flash does not render as expected. Consider the following example of my configuration:

appViewLayoutsdefault.ctp:


<!-- flash echoed below -->

<div id="main_flash">
  <?PHP echo $this->Session->flash(); ?>
</div>


appViewObjectsindex.ctp:


<!-- no flash echoed here -->


appViewObjectedit.ctp:


<!-- flash echoed below -->

<div id="edit_flash">
  <?PHP echo $this->Session->flash(); ?>
</div>


When I navigate to mysite.com/objects/, the flash (if set) successfully renders:


<div id="main_flash">Hello World!</div>


Now, whenever I edit an object mysite.com/objects/edit/12, the flash renders as shown below. The flash wouldn't render at all before I added the echo to edit.ctp:


<div id="edit_flash">Hello World!</div>


Is there any way to have my flash always render from default.ctp ie without having to echo the flash in individual view files? Right now, one flash statement works while the other is ignored.

链接地址: http://www.djcxy.com/p/57748.html

上一篇: R:由ddply组测试

下一篇: CakePHP默认的flash并不总是呈现