我有类似这样的内容:更改闪存消息的位置
控制器。
public function add() {
$this->layout = 'home';
$this->Session->destroy();
if ($this->request->is('post')) {
$this->Session->setFlash(__('xxx', true));
}
}
查看。 home.ctp
<div id="container">
<div id="header">
</div>
<div id="content">
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
<?php echo $this->Session->flash(); ?>
</div>
</div>
我的问题是:为什么flash的消息没有显示在页脚?好吧,我想要的是在窗体下面显示消息,但为了简化问题,使用此代码,消息也显示在顶部。但应该在页脚中。此外,如果我删除
<?php echo $this->Session->flash(); ?>
消息也显示在页面的顶部。
那么,我该如何改变这个Flash消息的位置呢?
编辑:
<?php var_dump($this->fetch('content')); ?>
输出:
string '<div id="flashMessage" class="message"> The user xxxxx</div>
<div class="users form">
<form action="/cake/users/add" id="UserAddForm" method="post" accept-charset="utf-8"><div style="display:none;"><input type="hidden" name="_method" value="POST"/></div> <fieldset>
<legend>
Add User
</legend>
<div class="input text required error"><label for="UserUsername">Username</label><input name="data[User][username]" maxlength="50" type="text" value="" id="UserUsername" class="form-er'... (length=1187)
无关紧要'Session :: flash()'被调用,所以这不是问题。这个请求是否一定要解雇?看起来有点奇怪,也会毁掉那里的会话。 – Ross