Multi Field Dropdown in Cakephp.
You get the picture – your database stores Firstname and Surname but you want Full Name to appear in a drop down. The hardest part for me was finding the solution because nothing seemed to list it appropriately under Google.
Eventually I found a simple solution using virtual fields and here it is.
In your model, my example uses Student, put the following:
var $virtualFields = array('fullname' => 'CONCAT(Student.forename, " ", Student.surname)');
Now in your controller create the data array with the following:
$options = array(
"fields" => array("id", "fullname"),
"order" => array("Student.fullname ASC"),
"conditions" => array('Student.published' => '1')
);
$students = $this->Student->find('list', $options);