Olá pessoal, aguem saberia me dizer o motivo:
Notice (8): Undefined property: UsersController::$Session [APP
\controllers\users_controller.php, line 50]
Code | Context
UsersController::edit() - APP\controllers\users_controller.php, line
50
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 83
Fatal error: Call to a member function setFlash() on a non-object in D:
\servidor\xampp\htdocs\cacex\app\controllers\users_controller.php on
line 50
Acontece nas actions, add, edit e delete.
segue o meu código do controller:
<?php
class UsersController extends AppController {
var $name = 'Users';
function area_restrita(){
}
function login(){
}
function logout(){
$this->redirect($this->Auth->logout()); // Efetuamos logout
}
function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid user', true));
$this->redirect(array('action' => 'index'));
}
$this->set('user', $this->User->read(null, $id));
}
function add() {
if (!empty($this->data)) {
$this->User->create();
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The user has been
saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not
be saved. Please,
try again.', true));
}
}
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid user', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The user has been
saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not
be saved. Please,
try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
}
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for user',
true));
$this->redirect(array('action'=>'index'));
}
if ($this->User->delete($id)) {
$this->Session->setFlash(__('User deleted', true));
$this->redirect(array('action'=>'index'));
}
$this->Session->setFlash(__('User was not deleted', true));
$this->redirect(array('action' => 'index'));
}
}
?>
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en