How to attach behaviors to yii built-in helpers (e.g., CHtml)?

How to attach behaviors to yii built-in helpers (e.g., CHtml)? Or other ways to extend a helper without changing the name of that helper?

Thanks.

Unfortunately, that’s not possible for now. The helpers are static and they don’t extend from CComponent (which is a requirement in order to attach behaviors).

You may simply create a new class (Html) and extend it from CHtml.

Thanks.

But some classes (e.g., CActiveForm) rely on CHtml, if I create a new class named Html, it makes no change on CActiveForm. Any good way to handle this? (Actually, I want to override some methods in CHtml like CHtml::activeCheckBoxList, which will in turn change CActiveForm::checkBoxList.)

I don’t know of any way to handle this. Hopefully we will see another approach about helpers in future. For example so that you can define the html-helper you want to use via CActiveForm::$htmlHelper or something.

Thanks! At this moment, my solution might be extending CActiveForm to ActiveForm, by replacing all "CHtml" with "Html" in CActiveForm.php and saving as ActiveForm.php