Pregunta

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'=>'dateTarget',
        '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!

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top