I have built a CakePHP app that creates appointments which have both a client and a doctor assigned to them from other tables in the database.
On the appointment add screen I want to be able to choose the Doctor name from a drop down (note the name consists of two fields, firstname and lastname and their is also a field called title for the prefix e.g. Mr). The information it SHOULD save though is the doctor_id as that is how the two tables are linked!
I have added the following to my view:
<?php echo $this->Form->input('doctor_id',array('label'=>'<strong>Choose Doctor</strong>'),$doctors); ?>
and then in my controller:
$this->set('doctors', $this->Appointment->Doctor->find('list'));
However this creates a list of random elements from the database. How can I get this to work? So the dropdown produced is something like:
<select>
<option value="1">Mr. John Doe</option>
<option value="2">Mrs. Jane Doe</option>
</select>