Is It Possible To Bold Some Items In Dropdown?

If I create a dropdown list with a group using

 'filter' => CHtml::listData(User::model()->findAll(),'id','name', 'role'),

I get a nice dropdown list with groups by role. The roles are rendered in boldface.

The problem I have is that I need to be able to have the user select the role or a user.

I have that working but if I apply a group, then I have

[b]  RoleA [/b]





 [b] RoleB[/b]




I am looking for a way to apply a bold to some of the items in my dropdown list.

Any advice is appreciated!

I found an example of using listOptions with dropDownList() but not with listData().

The filter is implying a dropdownlist but not sure how to massage it to accept a listOption()

A dirty solution would be to get listData to call a method in your model and your model to apply the styles; but is it even possible to apply, cross-browser, bold to a dropdown?


Hey Matt,

I was playing with a getAlias() function to return the data from the column with formatting but it didn’t work.

I also looked at listOptions but that seems to work with a drop down list and not the Filter => CHtml::listData()

Saw an example of using listOptions with dropDownList() that seemed a bit cumbersome but worked.

I know if I use the listData( value, display, group) the group is bolded, so they seem to be able to do it internally.

I need to look at the code. The group values are only headers, and cannot be selected. I need to allow the user to select the group or just a person.

I’ll dig into the code and see what I come up with.