Jump to:

23581 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » SS3: upload image to Widget

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 663 Views
  • Fraser
    Community Member
    46 Posts

    SS3: upload image to Widget Link to this post

    I'm creating a few widgets for a project I'm working on and it seems widgets do not have access to any of the other classes from outside the widget. I've tried adding a has_one static for both image and SiteTree classes (see example below for image example) and I am getting the same error when I try and add the cms field: Fatal error: Call to a member function FormAction() on a non-object in /..../sapphire/forms/FormField.php on line 139

    class AdBoxWidget extends Widget{
       static $title = "";
       static $cmsTitle = "Ad Box Widget";
       static $description = "Ad Box widget. To add an image, Title and Link";

       static $db = array(
          "Title" => "Text",
          "Link" => "Text",
          "AdLinkText" => "Text"
       static $defaults = array(
          "Title" => 'Ad Title',
          "Link" => 'http://',      
          "AdLinkText" => 'Click here for more info',
       static $has_one = array(
          'AdImage' => 'Image'

       function getCMSFields(){
          return new FieldList(
             new TextField("Title", "Ad Title"),
             new TextField("Link", "Ad Link"),
             new TextField("AdLinkText", "Text for Link"),
             new UploadField("AdImage", "Ad image")
       function getAd(){
          $output = new ArrayList();
             new ArrayData(
                   "Title" => $this->Title,
                   "Link" => $this->Link,
                   "AdLinkText" => $this->AdLinkText
          return $output;

  • swaiba
    Forum Moderator
    1796 Posts

    Re: SS3: upload image to Widget Link to this post

    I've no idea (helpful eh?) about SS3, but since widgets barely have made it as working and seem to be in teh same structure I can image it isn't better than the situation 2 years ago when I made this to work arroun the issue...


    The other solution is to use BBcode parser on the widget.

    However both workaround that require uploading the image first in file & images... would be very intrested to here these workarounds are not required in SS3 widgets...

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.