Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Widget not responding to updateCMSFields

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1685 Views
  • MarcusDalgren
    Avatar
    Community Member
    288 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
    30 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.

  • MarcusDalgren
    Avatar
    Community Member
    288 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.

    1685 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.