Hi,I have a person table and each person could have many work records in the 
works table.I use bake and I tell cake that a person has many work records, and 
in the works I tell cake that many works records could belong to a person 
record.It generates the code with t table of personand I can select a person to 
view and cake displays alll work records that belong to that person.When I 
click on the new work button i get this error instead of showing me the empty 
form with the table of person_id to select a person from that relates to the 
person- work link. Notice (8): Undefined property:  Work::$Person 
[APP\controllers\works_controller.php, line 30]
Code
            }

        }

        $people = $this->Work->Person->find('list');

WorksController::add() - APP\controllers\works_controller.php, line 30
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 268
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 240
[main] - APP\webroot\index.php, line 84
Fatal error: Call to a member function find() on a non-object in 
C:\VertrigoServ\www\usa\controllers\works_controller.php on line 30
==========================================
This is line 30
  $people = $this->Work->Person->find('list');
=
  $this->set(compact('people'));
===============================================================
Code generated in works_controller.php
<?php
class WorksController extends AppController {

 var $name = 'Works';
 var $helpers = array('Html', 'Form');

 function index() {
  $this->Work->recursive = 0;
  $this->set('works', $this->paginate());
 }

 function view($id = null) {
  if (!$id) {
   $this->Session->setFlash(__('Invalid Work.', true));
   $this->redirect(array('action'=>'index'));
  }
  $this->set('work', $this->Work->read(null, $id));
 }

 function add() {
  if (!empty($this->data)) {
   $this->Work->create();
   if ($this->Work->save($this->data)) {
    $this->Session->setFlash(__('The Work has been saved', true));
    $this->redirect(array('action'=>'index'));
   } else {
    $this->Session->setFlash(__('The Work could not be saved. Please, try 
again.', true));
   }
  }
  $people = $this->Work->Person->find('list');
  $this->set(compact('people'));
 }

 function edit($id = null) {
  if (!$id && empty($this->data)) {
   $this->Session->setFlash(__('Invalid Work', true));
   $this->redirect(array('action'=>'index'));
  }
  if (!empty($this->data)) {
   if ($this->Work->save($this->data)) {
    $this->Session->setFlash(__('The Work has been saved', true));
    $this->redirect(array('action'=>'index'));
   } else {
    $this->Session->setFlash(__('The Work could not be saved. Please, try 
again.', true));
   }
  }
  if (empty($this->data)) {
   $this->data = $this->Work->read(null, $id);
  }
  $people = $this->Work->Person->find('list');
  $this->set(compact('people'));
 }

 function delete($id = null) {
  if (!$id) {
   $this->Session->setFlash(__('Invalid id for Work', true));
   $this->redirect(array('action'=>'index'));
  }
  if ($this->Work->del($id)) {
   $this->Session->setFlash(__('Work deleted', true));
   $this->redirect(array('action'=>'index'));
  }
 }


 function admin_index() {
  $this->Work->recursive = 0;
  $this->set('works', $this->paginate());
 }

 function admin_view($id = null) {
  if (!$id) {
   $this->Session->setFlash(__('Invalid Work.', true));
   $this->redirect(array('action'=>'index'));
  }
  $this->set('work', $this->Work->read(null, $id));
 }

 function admin_add() {
  if (!empty($this->data)) {
   $this->Work->create();
   if ($this->Work->save($this->data)) {
    $this->Session->setFlash(__('The Work has been saved', true));
    $this->redirect(array('action'=>'index'));
   } else {
    $this->Session->setFlash(__('The Work could not be saved. Please, try 
again.', true));
   }
  }
  $people = $this->Work->Person->find('list');
  $this->set(compact('people'));
 }

 function admin_edit($id = null) {
  if (!$id && empty($this->data)) {
   $this->Session->setFlash(__('Invalid Work', true));
   $this->redirect(array('action'=>'index'));
  }
  if (!empty($this->data)) {
   if ($this->Work->save($this->data)) {
    $this->Session->setFlash(__('The Work has been saved', true));
    $this->redirect(array('action'=>'index'));
   } else {
    $this->Session->setFlash(__('The Work could not be saved. Please, try 
again.', true));
   }
  }
  if (empty($this->data)) {
   $this->data = $this->Work->read(null, $id);
  }
  $people = $this->Work->Person->find('list');
  $this->set(compact('people'));
 }

 function admin_delete($id = null) {
  if (!$id) {
   $this->Session->setFlash(__('Invalid id for Work', true));
   $this->redirect(array('action'=>'index'));
  }
  if ($this->Work->del($id)) {
   $this->Session->setFlash(__('Work deleted', true));
   $this->redirect(array('action'=>'index'));
  }
 }

}
?


Should cakephp generated code point to what?
Thanks
JIm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to