Message not flashing in cakephp edit function
Simple question for some I am sure. The function itself is doing what is asked, but the message is not being flashed when actioned.
Function below:
function edit($id = null) {
if($this->Auth->user('id')==$id) {
$this->set('user', $this->User->read(null, $id));
} else {
$this->Session->setFlash(__('You are not authorized to edit other member profiles', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('Member profile saved', true));
$this->redirect(array('action' => 'index'));
} else开发者_运维知识库 {
$this->Session->setFlash(__('Member profile could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
}
$groups = $this->User->Group->find('list');
$this->set(compact('groups'));
}
Still learning the cakephp ropes and kindling some very old PhP skills - so bear with me! Thanks!
Add another line underneath
echo $this->Session->flash('auth');
Like this:
echo $this->Session->flash();
This will show regular flash messages
passing 'auth' to the flash method will only show auth flash messages and nothing else. See http://api13.cakephp.org/class/session-helper#method-SessionHelperflash for more information.
精彩评论