Yii 1.1.9 allows to override Core Classes, but as far as I know we have no guide nor directions to make the override. Looking at the code I found the following in YiiBase.php:
I downloaded build, but it seems to have other requisites, like PHPUnit. There is a ‘core developer guide’ or something similar somewhere?
At this point I’m lost because I cant find a guide to Override the CHtml Core class.
I tried to modify the $_coreClasses array in YiiBase but nothing happens. Could anyone post clear directions to update this array in order to override a class, like CHtml in my case?
There’s no need to change Yii::$classMap when you want to extend a framework class. Just put the file that contains your extended class in an imported directory (protected/components). Use $classMap only when you want to replace a class entirely. In this case the replacement class must have the same name as the original class (for obvious reasons) - it means that you can’t extend the replacement class from the original one.
and made a full copy of the original CHtml class, replacing the desired methods.
That’s not ideal, but it works without modifying the core class.
By the way, I need to use the same class name because I want to override the behavior of CHtml in the whole application, including zii components.
Would be great to be able to inherit the original class, override the desired methods, and use the new class with a new name in the application mapping the original name to the new name. No idea on how can it be done, be would be great =)
ok I have been trying to do the same thing. You’ve gotten so close. How does one simply override only the “method” that you want to change/alter in Chtml Class. For example hiddenField() function does not allow values that are arrays. I simply want to override that method when I am building a form any thoughts on how to override specific methods not the entire class itself.
yes I have view your post a ton and it would accomplish what I need. MY orignal problem was that when I tried to strore checkbox list values in the DB they were be stored as an Array? rather than the individual values. But I do not want to highjack the thread and post elsewhere for a solution I will edit this post once I find the appropriate discussion.