Add new item to CHtml in yii

I work with Yii with doctrine 2. I have a problem, the datetime in doctrine 2 is an object of the DateTime class, and I cannot update it using the usual CHtml or form methods.

How to add a new element to CHtml that can handle this situation.

- Best regards Moe Far

+3
source share
1 answer

You can extend the class CHtmland add your own functions. The code should look something like this:

class MyHtml extends CHtml {
    // add you own logic or override CHtml functions

    public static function myFunction() {
        return 'yeah!'; 
    }
}

Then you can use MyHtml::myFunction()as well as use all the standard CHtml functions.

Yii: Yii

+2

All Articles