vibha
vibha

Reputation: 129

Notice (8): Undefined property:

Please help me with this: am I missing something?

I am getting following error:

Notice (8): Undefined property: Property::$Project [APP\controllers\properties_controller.php, line 614]

// This is code where warning occurs

$projects = $this->Property->Project->find('list');

and in project.php (model file)

var $hasMany = array(
    'Property' => array(
        'className' => 'Property',
        'foreignKey' => 'project_id',
        'dependent' => true,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

Upvotes: 3

Views: 1560

Answers (2)

chetanspeed511987
chetanspeed511987

Reputation: 2025

you have to write in properties_controller.php

var $uses = array('Project');

then you use

$projects = $this->Project->find('list');

Also add in property.php

var $belongsTo = 'Project';

Upvotes: 0

TuteC
TuteC

Reputation: 4382

Add in property.php var $belongsTo = 'Project'.

Upvotes: 1

Related Questions