私はこのようなものを持っています:
コントローラ。
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>
私の質問は、フラッシュメッセージがフッターに表示されないのはなぜですか?さて、私が欲しいのはフォームの下にメッセージを表示することですが、問題を単純化するために、このコードではメッセージも上部に表示されます。ただし、フッターに含める必要があります。また、削除した場合
<?php echo $this->Session->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)