开发者

How can I override cake FormHelper?

I need to change the $form->create behaviour, so I created a helper to use instead of the native formHelper:

SlugHelper:

App::import('Helper', 'Form');
class SlugFormHelper extends FormHelper {

    public funct开发者_运维百科ion create() {
        return "error";
    }
}

In AppController:

public $helpers = array('SlugForm' => 'Form');

And in the View:

$form->create(); 

but it still calls the native $form->create();


Just a thought - but shouldn't you define helpers in the controller by doing something like this:

public $helpers = array('SlugForm', 'Form');

Rather than what you had with "SlugForm => Form". Hope that helps!


I've just been trying to do the same thing. I think it's quite simple, just...

public $helpers = array('SlugForm');


try with:

public $helpers = array(
    'Form' => array('className' => 'MyForm'),
);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜