Jump to:

5541 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Can't add images to the CMS

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

Page: 1
Go to End
Author Topic: 1254 Views
  • DanStephenson
    Community Member
    115 Posts

    Can't add images to the CMS Link to this post

    Greetings folks,

    I'm working on my first SilverStripe powered site. I am building a layout that is going to have several different tabs in the CMS, each for a different type of data. One of these tabs, "Resellers", should allow for the user to upload 4 reseller logos, to be displayed at the bottom of the page.

    I am using this code inside my HomePage.php file:

    class HomePage extends Page {
    'Reseller1' => 'Image',
    'Reseller2' => 'Image',
    'Reseller3' => 'Image',
    'Reseller4' => 'Image'

    function getCMSFields() {
    $fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller1', 'Reseller Logo 1'));
    $fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller2', 'Reseller Logo 2'));
    $fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller3', 'Reseller Logo 3'));
    $fields->addFieldToTab('Root.Content.Resellers', new ImageField('Reseller4', 'Reseller Logo 4'));

    And when I run my /db/build/?flush=1 I get this error message:

    FATAL ERROR: DataObject::__construct passed The value 'Reseller1'. It's supposed to be passed an array, taken straight from the database. Perhaps you should use DataObject::get_one instead?
    At line 83 in C:\wamp\www\valtus-ss\sapphire\core\model\DataObject.php

    Can anyone help me solve this issue?

  • Fuzz10
    Community Member
    787 Posts

    Re: Can't add images to the CMS Link to this post

    You need to link your images to your class by defining a relationship.

    static $has_one = array(
          'Thumbnail' => 'Image',

  • Aram
    Community Member
    598 Posts
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.