Images In Chtml Dropdown

I want to be able to put an image inside the chtml::dropDownList.

But the dropdown list doesn’t display the html tags.

Is there a way to set the type=raw?

There has to be a different image for each item in the drop down list.





<?php echo CHtml::dropDownList("banner1", array(''=>''), model::getBanners()); ?>








public static function getBanners()

    {        

        $criteria = new CDbCriteria();

        $criteria->condition = 'status = '.Banner::STATUS_ACTIVE.'';

        $criteria->order = "modified DESC";

                

        $activeBanners = Banner::model()->findAll($criteria);


        $bannerArray=array();

        

        foreach ($activeBanners as $banner)

        {

            

            $bannerImage = $banner->image;

            

            $bannerArray[$banner->id] = '<img src="'.$bannerImage.'">';

        }


     return $bannerArray;

        

    }




try echoing the image tag only I’ve not tested it just an idea! hope it works, hope the image path is correct.


echo CHtml::tag('img', $htmlOptions);

You can’t put an image in select although you could try it with css or use jquery plugin that will convert your select into a dropdown with images