789 Posts in 335 Topics by 301 members
|Go to End|
14 October 2009 at 9:23pm
I have been trying to decorate the widget class in order to get some more database fields and add some custom fields to the widgets that are shared between all the widgets.
Adding the database fields wasn't a problem but adding an updateCMSFields has no effect. I've made sure that all the widgets inheriting from the base class call parent::getCMSFields to make sure that getCMSFields is actually called on the Widget class but no luck.
Has anyone tried this and succeeded or does anyone know why this fails?
Is it because the decorator is on a parent class and not the class that is actually used?
27 January 2010 at 8:54am
A bit late maybe...
I have not decorated a widget myself. But what I would check first is that I do not forget to call my parent class with parent::getCMSFields(). Or check that $this->extend('updateCMSFields', $fields) is implemented from one of the baseclasses.
27 January 2010 at 9:04am
Thanks for the reply!
The problem is indeed that no widgets I have worked with so far (essentially the widget base class and the blog widgets) call $this->extend() so adding/removing fields on them doesn't work.
I personally think that every widget should call $this-extend() before returning their fields and so should the base class. That way you can either decorate the base widget class if you want all your widgets to share some special field (which was my case) or you can add/remove fields from one of the widget implementations.
If I remember correctly, the blog widgets don't call parent::getCMSFields() so even if the base class called $this->extend() on the empty fieldset they'd still have to be changed.
|Go to Top|