Confused about inheritance here.
Here is the helpers var from Cake's controller file.
var $helpers = array('Html', 'Form', 'Javascript', 'Ajax');
AppController extends this so I think that the helpers should be
available there.
My controller AjaxtestsController extends Appcontroller and so they
should also be available there
However when I do the following:
$this->set('myvar', $this->javascript->object($arr));
or
$this->set('myvar', $javascript->object($arr));
I get the following error:
Notice (8): Undefined property: AjaxtestsController::$javascript [APP
\controllers\ajaxtests_controller.php, line 26]
Code | Context
$arr = array(
"item 1",
"item 2"
)
//debug($this);
$this->set('myvar', $this->javascript->object($arr));
AjaxtestsController::edit() - APP\controllers
\ajaxtests_controller.php, line 26
Object::dispatchMethod() - CORE\cake\libs\object.php, line 115
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 245
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 211
[main] - APP\webroot\index.php, line 88
Fatal error: Call to a member function object() on a non-object in C:
\htdocs\caketest\app\controllers\ajaxtests_controller.php on line 26
CODE POSTED BELOW
<?php
class AjaxtestsController extends AppController
{
var $helpers = array('Javascript');
function index()
{
$this->pageTitle = 'Index Page';
}
function view()
{
$this->pageTitle = 'View Page';
}
function edit()
{
$this->pageTitle = 'Edit Page';
$arr = array('item 1', 'item 2');
//debug($this);
$this->set('myvar', $this->javascript->object($arr));
}
}
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---