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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

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

Adding image upload to cms


Go to End


3 Posts   1309 Views

Avatar
StuM

Community Member, 59 Posts

8 September 2008 at 9:30am

Edited: 08/09/2008 9:36am

Hi All,

I tried the following tutorial:

http://doc.silverstripe.com/doku.php?id=imageupload

but it doesn't seem to work, no images are uploaded.

The indexes are created and present in the table for the page type, and images can be uploaded via Files/Uploads, so that works as well.

my code:

...
static $has_one = array(
		'LeftAd' => 'Image',
		'LeftBottomAd' => 'Image'
	);

...

public function getCMSFields() {
   		$fields = parent::getCMSFields();
   		$fields->addFieldToTab('Root.Content.LeftAdvertisement', new SimpleImageField('LeftAd', 'Left Top Ad'));
   		...
   		$fields->addFieldToTab('Root.Content.LeftAdvertisement', new SimpleImageField('LeftBottomAd', 'Left Bottom Ad'));
		...
		return $fields;
	}

any clues???

I'm using daily build version from Monday 1st September

Avatar
StuM

Community Member, 59 Posts

8 September 2008 at 9:55am

OK, just changed the SimpleImageField to an ImageField and it works, so all good now

Avatar
Willr

Forum Moderator, 5523 Posts

8 September 2008 at 12:12pm

Ive updated the doc. Should use an ImageField anyway. SimpleImage fields are normally for front end eg sign up forms.