Now, I was trying to use the new default config options for the widget factory. I’ve been replacing the default delete link image in my CButtonColumns manually so far, and decided to try specifying that option in my config using the new widget factory default configuration.
I’ve got this in my /config/main.php, under components:
Your question implies, that subclassing CButtonColumn is not easy. I would not necessarily agree to that:
class MyButtonColumn extends CButtonColumn
{
public function init()
{
$this->viewButtonImageUrl=Yii::app()->request->baseUrl.'/img/myViewButtonImage.gif';
return parent::init();
}
}
I ended up doing the same. Subclassing per se is not a problem, I just have to change the CButtonColumn to MyButtonColumn in many places => update many files on the server, but it works, so it is OK
Thanks for you post and answers I had the same questioning and it helped me a lot.
But it leads to a general question about extending existing objects. In this case where would you put the file containing the MyButtonColumn extended object : protected/components or protected/extension ? I must admit this is not always very clear to me. I guess both would do but what is the best practice and why ?
There’s no standard for this. For a start just put it into /components. When you find, that this folder gets too crowded, think about how you can reorganize the files. This really depends on your project and how many custom classes you need. You could for example create “/components/widgets” for all your widgets. Just remember that you must import all your custom folders explicitely in your config/main.php.