开发者

How can I override cake FormHelper?

开发者 https://www.devze.com 2023-02-13 05:21 出处:网络
I need to change the $form->create behaviour, so I created a helper to use instead of the native 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

精彩评论

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