0

I have something like this:

controller.

public function add() {
        $this->layout = 'home';
        $this->Session->destroy();

        if ($this->request->is('post')) {
                $this->Session->setFlash(__('xxx', true));

        }
    }

view. 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>

My question is: Why the flash message is not showed in the footer? well, what I want is show the message below the form, but to simplify the problem, with this code the message is also showed in the top. But should be in the footer. Also if i delete

 <?php echo $this->Session->flash(); ?>

the message is also showed on the top of the page.

So, how can i change the position of this flash message?

Edit:

<?php var_dump($this->fetch('content')); ?>

output:

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)
4

2 回答 2

1

您正在将布局设置为“家”,对吗?你创建了一个home.ctpunderviews/layouts吗?我问你是因为你显示的视图看起来像 Cake ( ) 附带的默认布局default.ctp

对我来说,代码看起来不错,只要确保你显示的是正确的布局。

于 2012-09-09T15:44:42.057 回答
1

当我删除我的时 <?php echo $this->Session->flash(); ?>,我没有收到闪信。我认为您应该考虑@clapas 的回答。

于 2012-09-09T16:01:47.457 回答