开发者

CakePHP 1.3 - app_controller.php $helpers were not inherited

CakePHP: 1.3

OS: Ubuntu 10.10

Apache: 2.2

PHP: 5.3+

MySQL: 5.1

I have the /app/app_controller.php

class AppController extends Controller {
    var $helpers = array('Html', 'Form', 'Ajax', 'Javascript');
}

When I try use any helpers above, I get error... because it was 'not loaded' (you understand?!)

But, when I put the same code in any Controller, for example:

class PostsController extends AppController {
    var $helpers = array('Html','Ajax', 'Javascript', 'Form');

Works great :)

BUT! What I did wrong in app_controller.php? app_controller not load $helpers? the documentation says it load "everything".

Sorry my English ... I am Brazilian a开发者_如何学Pythonnd I need to use "Google Translate " in some cases =P


Since you are using PHP5, try using "public" instead of var when declaring the helpers array. I think that will correct the inheritance issue.

class AppController extends Controller {
    public $helpers = array('Html', 'Form', 'Ajax', 'Javascript');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜