m.dhouibi
(Mohamed Dhouibi1985)
1
Hello
I have my database table :
currency(id, c_code, c_name);
on my view :
<?php
$currency = CHtml::listData(FiCurrency::model()->findAll(array('order' => 'id')), 'id', 'c_code');
echo $form->dropDownListRow($model, 'currency',$currency);
?>
This works very well,(list of codes) but I need to show in the list code+name
c_code c_name
c_code _c_name
c_code _c_name
…
How can I do this please?
If U check this :
http://www.yiiframework.com/doc/api/1.1/CHtml#listData-detail
U will see that U can pass function instead of attribute name, something like
$currency = CHtml::listData(FiCurrency::model()->findAll(array(‘order’ => ‘id’)), ‘id’, function (FiCurrency){
return CHtml::encode($this->c_code.$this->c_name);
});
oligalma
(Marc Oliveras)
3