I am new to using cake and am having difficulty at one of the first hurdles of my first application (outside of all the tutorials I've done!)
I have three models:
Property
Dealers
Photos
Dealers have many properties, properties have many photos.
Through reusing code from a tutorial, when adding a property, I can get a dropdown of all the dealers. The code looks something like this:
However, when I try and reuse similar code in the Photos controller, such as this:PHP Code:<?php
class PropertiesController extends AppController {
var $name = 'Properties';
var $helpers = array('Html', 'Form' );
function index() {
...
}
function add() {
if (empty($this->data)) {
$this->set('dealers', $this->Property->Dealer->generateList());
$this->render();
} else {
// create property
}
}
}
I get horrific errors like this:PHP Code:<?php
class PhotosController extends AppController {
var $name = 'Photos';
var $helpers = array('Html', 'Form' );
function add()
{
if (empty($this->data)) {
$this->set('properties', $this->Property->Property->generateList());
$this->render();
}
else
{
// add photo
}
}
}
?>
Can anyone help me overcome this?Code:Notice: Undefined property: PhotosController::$Property in /Applications/MAMP/htdocs/property_inv/app/controllers/photos_controller.php on line 9 Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/property_inv/app/controllers/photos_controller.php on line 9 Fatal error: Call to a member function generateList() on a non-object in /Applications/MAMP/htdocs/property_inv/app/controllers/photos_controller.php on line 9
Many thanks!




Bookmarks