i have two tables
voices:
- id
- Lecturer_id
- ...
Lecturers:
- id
- Lecturer
- code
add.ctp is for voices but there is a drop-down which list lecturers. then the id of Lecturer should be saved in Lecturer_id of voices table
i solved the issue and wanted to share it with u:
in Voice module:
public $belongsTo = 'Lecturer';
and i added some code to Add action in Voicescontroller:
$this->set('lecturers', $this->Voice->Lecturer->find(
'list',
array(
'fields' => array('Lecturer.Lecturer'),
'order' => array('Lecturer.Lecturer')
)));
and in add.ctp for my dropdown:
echo $this->Form->input('lecturer_id', array(
'options' => array($lecturers),
'empty' => '(choose one)'
));