Jump to:

633 Posts in 170 Topics by 237 members

Widgets

SilverStripe Forums » Widgets » Widget not responding to updateCMSFields

Discuss SilverStripe Widgets.

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba

Page: 1
Go to End
Author Topic: 1366 Views
  • Smurkas
    Avatar
    Community Member
    277 Posts

    Widget not responding to updateCMSFields Link to this post

    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?

    Kindly,
    Marcus

  • Capt. Morgan
    Avatar
    Community Member
    31 Posts

    Re: Widget not responding to updateCMSFields Link to this post

    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.

  • Smurkas
    Avatar
    Community Member
    277 Posts

    Re: Widget not responding to updateCMSFields Link to this post

    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.

    1366 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.