0

I am using CakePHP 2.7.

I generated MVC code using Cake Bake.

Running the project generates the following error message:-

Undefined variable: key [CORE\Cake\View\Elements\Flash\success.ctp, line 1]

What is causing this error?

drmonkeyninja
  • 8,490
  • 4
  • 31
  • 59
Trliok
  • 361
  • 1
  • 17
  • 4
    Please show that code where you got error?then only anyone can help you.thanks. – Alive to die - Anant Sep 10 '15 at 06:12
  • \\\lib\Cake\View\Elements\Flash\success.php – Trliok Sep 10 '15 at 06:46
  • Do you know which controller action is rendering this template? Could you post that code as from what your error message is saying `$key` is not getting set. – drmonkeyninja Sep 10 '15 at 07:08
  • this is my controller code $this->Flash->success(__('The role has been saved.')); and error message is Undefined variable: key [CORE\Cake\View\Elements\Flash\success.ctp, line 1] – Trliok Sep 10 '15 at 07:18
  • 1
    You need to show more code - what's relevant is how you are rending the flash message, it sounds like a mismatch between [the old way](https://github.com/cakephp/cakephp/blob/2.6/app/View/Layouts/default.ctp#L45) (which uses the session component/helper), and [the new way](https://github.com/cakephp/cakephp/blob/2.7/app/View/Layouts/default.ctp#L45) (which depends on the flash component/helper) - they aren't compatible. Please **edit the question** to add information - do not write comments. – AD7six Sep 10 '15 at 07:36
  • 3
    Probably fixed with https://github.com/cakephp/cakephp/pull/7379 – mark Sep 10 '15 at 08:00
  • @mark : $class will use instance of $key.? – Trliok Sep 10 '15 at 09:16
  • I had a [similar "missing key" error in CakePHP 2.7](http://stackoverflow.com/questions/32041587/how-to-define-flashhelper-component-element-for-general-autherror-message), but it was related to the **authentication** flash message - maybe the answer there is also helpful for your problem... – Oops D'oh Sep 11 '15 at 22:13

0 Answers0