How Do I Concatenate In Chtml::listdata?

Here is my code

$records = Sotype::model()->findAll();

            $list1 = CHtml::listData($records, 'soType','soType - soDescription');

            echo $form->dropDownList($model,'Classification', $list1, array('empty' => '(Select Type)'));

It should do something like:

soType = value of field (which is properly working)

soType - SoDescription = name of field (I cant make this work)

can someone help me concatenate soType and soDescription as a name field? thanks :) im so lost for hours…


you want to fechAll DB records so you must be foreachloop

for e.g


        $data=VenueEvent::model()->findAll("rk_venue_id='".$venue_id."' AND status='1'");


        echo "";

        foreach($data1 as $value=>$event_name){

            echo CHtml::tag('option', array('value'=>$value),CHtml::encode($event_name),true);


or create the simple PHP foreach loop…

echo " Weekday: <select name='weekday'>";

foreach ($days as $value) {

echo '<option value="'.$value.'">'.$value.'</option>\n';

} echo '</select><br />';

write a method in the model

 public function getConcatened()


                return $this->soType.' - '.$this->soDescription;


in view, change

$list1 = CHtml::listData($records, 'soType','concatened');