mharkie yoeh
mharkie yoeh

Reputation: 1

CakePHP error: Call to undefined method FlashComponent::error()

I am now practising the blog tutorial of CakePHP, and I follow every single step or instruction of it. Still, I'm not able to add posts because this error pops up:

Error: Call to undefined method FlashComponent::error() 
File: C:\xampp\htdocs\sembreak\app\Controller\PostsController.php   
Line: 29

What is the reason for this error and how can I solve this problem?

Upvotes: 0

Views: 1629

Answers (1)

drmonkeyninja
drmonkeyninja

Reputation: 8540

You want to be using $this->Session->setFlash() not $this->Flash->error() for versions of CakePHP lower than 2.7.0:-

$this->Session->setFlash(__('Unable to add your post.'));

The clue is in the error message you were getting "Call to undefined method".

Upvotes: 1

Related Questions