Dropdownlist Not Encoded

How to do a dropDownList where the values are not encoded? Yii 1 was simple: ‘encode’ => false

I think you are talking about "encodeLabels" property…

No, I am talking about the dropDownList itself. I have a dropdown list with a tree structure. This requires HTML within the options.

From what I can see, Yii2 has gone backwards in this respect and does not offer an option to switch off encoding.

Yes. The options are rendered by BaseHtml - renderSelectOptions();

There is no way to not encode other than edit the core file. Not good, backward step.

Now, some may argue that it’s invalid to use HTML within option tags, however Yii quite happily adds


 

outside the encoding (these are the only tags I am using also).