Hi, I've created a drop down list of user's names, that I've concatenated from first_name and last_name in a database table. And it works perfectly! Here's what I've got:
User Model:
public function getFullName()
{
return $this->first_name . " " . $this->last_name;
}
StudentRecordController, in actionCreate():
$students = CHtml::listData(User::model()->with('studentRecords')->findAll(), 'id', 'FullName');
And in views/studentRecord/_form.php:
<?php echo $form->dropDownList($model, 'user_id', $students, array('empty' => 'Select Student Name')); ?>
My question is, how is the getFullName() method called by the third argument to listData, which is 'FullName'? The "get" is parsed out? If I use the full method name instead (getFullName), it does'nt work. And actually fullname, fullName, FuLlNaMe all work.
Bear in mind, that with this approach, you have to include the $students array in the render method of the controller and the view.
Larry Z.