How to display combobox 2 values

I want to displaying combobox

<select>

<?php foreach($car as $rows) { ?>

<option value="<?php echo $rows->id;?>"><?php echo $rows->id; echo "|"; echo $rows->name; ?></option>

<?php } ?>

</select>

how to script in Yii ?

<?php echo $form->dropDownList($model, ‘car’, CHtml::listData(ModelCar::model()->findAll(‘id’, ‘name’));?>

Thank you

Hi my friend if I got your question this is what you’re asking for




//On the model

	public function toList()

	{

		$model = Department::model()->findAll('');

		return CHtml::listData($model, 'CodDepartment', 'CodDepartment'." | ".'DescDepartment');

	}


//On the form

	<?php echo $form->dropDownList($model,'CodDepartment', Department::toList(), array('empty'=>'Select a value...')); ?>



Good luck bro, if this is not what you need tell us and we’ll try to help you

Thank you so much… :)