Jump to:

794 Posts in 409 Topics by 304 members


SilverStripe Forums » Widgets » Linking Dataobjects in Widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 677 Views
  • Azlein
    Community Member
    5 Posts

    Linking Dataobjects in Widget Link to this post


    I'm trying to link some DataObjects to a Widget. In my particular case, I have

       static $has_many = array(
          'Buttons' => 'SocialButton'

    in my Widget and

       static $has_one = array(

    in my DatabObject.

    I'm trying to do this with a GridField, but this fails:

    $fields = parent::getCMSFields();
          $gridField = GridField::create('Buttons', 'Some text', $this->Buttons(), new GridFieldConfig_RelationEditor());//new GridField("Buttons", "Buttons", $this->Buttons(), $gridFieldConfig);
          $fields->push($gridField); //This line causes a Internal Server Error

    So, my question is - is it allowed to use a GridField in a Widget? If yes, why is the $fields->push call creating the error? If not, are there any alternatives?

    Thanks in advance.

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.