Jump to:

23554 Posts in 19381 Topics by 2892 members

General Questions

SilverStripe Forums » General Questions » SS3 Beta UploadField on DataObject issues

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: 543 Views
  • nimesodelta
    Community Member
    18 Posts

    SS3 Beta UploadField on DataObject issues Link to this post

    Hi All,

    Not sure if I'm missing something here or maybe someone can tell me this is a know issue.

    I have a simple DataObject called 'Brand' like so...

    class Brand extends DataObject {

       static $db = array(
          "Title" => "Varchar(256)",
          "WebsiteLink" => "Varchar(256)"

       public static $has_one = array(
          "HomePage" => "HomePage",
          "Logo" => "Image"

       public static $summary_fields = array(
       function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Main", new TextField("Title", "Title"));
          $fields->addFieldToTab("Root.Main", new TextField("WebsiteLink", "Website Link"));
          $fields->addFieldToTab("Root.Main", new UploadField("Logo"));
          $fields->removeFieldFromTab("Root.Main", "HomePageID");
          return $fields;

    And 'Brands' can be added to a page using the new GridField like:

    $brandsConfig = new GridFieldConfig_RelationEditor();
    $brandsTable = new GridField("Brands","Brands",$this->Brands(),$brandsConfig);

    everything so far is cool BUT when I try to attach a image to a 'Brand' object (adding or editing) it seems the form action is messing up and the DataObject has no controller action kicking in to deal with the 'upload' method... it returns a 404.... eg:

    http://zqpublic.nimeso/admin/page/edit/EditForm/field/Brands/item/1/ItemEditForm/field/Logo/upload (Wont work)

    http://zqpublic.nimeso/admin/page/edit/EditForm/field/HeaderImage/upload (Will work - used in my base Page class)

    Cheers guys! Great job so far! looking Asum!

  • Phat
    Community Member
    8 Posts

    Re: SS3 Beta UploadField on DataObject issues Link to this post

    Hi nimesodelta,

    The problem is that when an image is uploaded, it cannot make a link (LogoID) back to Brand dataobject since the Brand has not been actually created at the time the image is uploaded. A Brand data object is actually created when you click Create button.

    If you try to save (create) a Brand first and then upload a image, it works fine...I know this is not a solution but hope the info is helpful.

    Let me know if you can fix the problem


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.