CHtml::listData from a relation

When using CHtml::listData($models, $valueField, $textField) with a Relational Active Record there doesn't seem to be any way to set the $valueField or $textfield to use on of the relations members.

The following won't work:



CHtml::listData($relationalActiveRecord, 'personId', 'personRelation->name')

Is there some way to do this I'm missing?

listData doesn't support this usage. You should directly construct the needed data by using a simple foreach loop:



foreach($models as $model)


    $listData[$model->personId]=$model->personRelation->name;


Thanks for the reply,

Are there any plans to implement this for listData?

Although the implementation is easy, we do not have plan yet to do it. The main reason is because we want to keep the usage simple, consistent and efficient.