I have a translation file that includes all site categories.
How i can take this array and use it in a CActiveForm listbox?
I have a translation file that includes all site categories.
How i can take this array and use it in a CActiveForm listbox?
if the file return array of key value you can do the following:
$array = include yii::getPathOfAlias('path.to.file'),'/filename.php';
CHtml::listBox('name',select,$array);
drmovi, thanks a lot for your help.
That worked perfectly but I run into another problem.
The array items contains to give space. But yii converts ‘&’ character to & when building the list.
Is there any way to keep the space?
ok fine this is because yii encode the key and value try this code which disable encoding value
CHtml::listBox('name',select,$array,'htmlOptions'=>array('encode'=>false));
Thanks a lot for your help.
It’s just need a bit of correction
CHtml::listBox('name',select,$array,array('encode'=>false));