Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

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

Can't add images to the CMS

Go to End

3 Posts   1892 Views


Community Member, 116 Posts

13 February 2009 at 5:44am

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?


Community Member, 791 Posts

13 February 2009 at 10:15pm

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

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

Carbon Crayon

Community Member, 598 Posts

13 February 2009 at 11:59pm