ドロップダウンリストにすべてのプロジェクトリーダーの名前を表示したいと思います。
プロジェクトリーダーは、会社で働く従業員のほんの一部です。
これが私のテーブルです:
project_leaders
,----,----------------,
| id | hr_employee_id |
|----|----------------|
| 1 | 18 |
'----'----------------'
projects
,----,------,-------------------,
| id | name | project_leader_id |
|----|------|-------------------|
| 1 | cake | 1 |
'----'------'-------------------'
hr_employees
,----,------,---------,
| id | name | surname |
|----|------|---------|
| 18 | joe | dirt |
'----'------'---------'
私のProjectsControllerは次のようになります。
public function add() {
if ($this->request->is('post')) {
$this->Project->create();
if ($this->Project->save($this->request->data)) {
$this->_sendProjectRequestEmail($this->Project->getLastInsertID() );
$this->Session->setFlash(__('The project has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The project could not be saved. Please, try again.'));
}
}
$this->set('projectLeaders',$this->Project->ProjectLeader->find('list');
}
これは、名前と名前ではなく、プロジェクトリーダーのIDのみを返します。したがって、Joe Dirtの代わりに、1を返します。
$ this-> Project-> ProjectLeader-> HrEmployee-> find('list')を実行しようとしましたが、すべての従業員が一覧表示されます。
フィールドを指定しようとしましたが、不明なフィールドエラーが返されます。
私は何が間違っているのですか?