Artisan
Artisan

Reputation: 4112

SessionComponent::setFlash

I'm using CakePHP 2.

This is my controller.

class GroupsController extends AppController {
  public $helper = array('Html', 'Form', 'Session');
  public function edit($id = null) {
    if (empty($this->request->data)) {
      $this->request->data = $this->Group->findByGroupId($id);
    } else {
      if($this->Group->save($this->request->data)) {
        $this->Session.setFlash('Saved!!!');
        $this->redirect(array('action' => 'index'));
      }
    }
  }
}

When I pressed the save button on the page groups/edit/1, I got an error. "Error: Call to undefined function setFlash()"

Fortunately, the changes I made were save to the database, I really don't get it, because setFlash() is a method of SessionComponent.

Please help, thanks. Kongthap.

Upvotes: 0

Views: 395

Answers (1)

Krishna
Krishna

Reputation: 1540

try this ::

$this->Session->setFlash('Saved!!!');

Upvotes: 1

Related Questions