문제

So my problem is that i know how to load an Helper into the Controller but it´s only working for HtmlHelper not for FormHelper.

i load it into my method like this:

//this method is from an controller like page_controller    
function addField($pageID) {

    if($this->RequestHandler->isAjax()) {
        $this->autoRender = false;
    }

    App::import('Helper', 'Form');

    $form = new FormHelper();

    return $form->input('test');

}

I got some error like can´t load on unknown stdClas::$model etc.

HtmlHelper works well when i ouput it with link method i got a full rendered link in my view.

I wont only to load on Ajax an new input but it won´t work and i do not know why... Hope you understand my problem.

도움이 되었습니까?

해결책

what you are doing there is awfully wrong. there is good reason why this doesn't and should never work your way.

use the normal MVC procedure as outlined in the documentation and tutorials. http://book.cakephp.org/

in your case this means that you NEED to always use a view template (/views/controllername/actionname.ctp) and put your form stuff in there.

다른 팁

Change this below code

App::import('Helper', 'Form');

$form = new FormHelper();

into this below code

App::import('Helper', 'Form');

$form = new FormHelper(new View());

then use $form like this $form->input('name');

you are missing (new View())

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top