开发者

CakePHP fails loading $ajax->form with Error 503 Service Unavailable

When I try to make an $ajax->form() call within my view, the server responds with: Error 503 Service Unavailable.

I have loaded:

App::Import('Ajax');
$ajax = new AjaxHelper();

(Within my view)

And then:

$ajax->form(array('type' => 'post',
  array('type' => 'post',
    'options' => array(
        'model'=>'User',
        'update'=>'dateTa开发者_如何学JAVArget',
        'url' => array(
            'controller' => 'comments',
            'action' => 'edit'
        )
    )
));

The only error I can seem to find is:

Undefined property: AjaxHelper::$Form

From within app/tmp/logs/debug.log

It should be noted that I tried echo'ing: get_class_methods($ajax) and it showed that form IS available.

Can someone advise me on how to proceed from here?

Thanks!


The AjaxHelper depends on the FormHelper (plus the HTMLHelper and JavascriptHelper). If you manually create an instance of the AjaxHelper you also have to create those dependencies (depending on the functionality you intend to use). It's done in the following way:

App::Import('Ajax');
$ajax = new AjaxHelper();
$ajax->Form = new FormHelper();

However, usually the helpers you want to use are added to the $helpers array of your controller(s):

public $helpers = array('Ajax');

See also http://book.cakephp.org/view/1096/Using-Helpers

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜