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.

General Questions /

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

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

Pre-populate ImageField by ID

Go to End

2 Posts   1201 Views


Community Member, 197 Posts

14 January 2011 at 4:19pm

I want to allow certain registered users the ability to upload images from the front-end of SilverStripe as well as browse the file store for images.

How can I pre-populate the ImageField with the image with an ID of 5? This does NOT work:

new ImageField('TeaserImage', 'Teaser Image',5), 

I get this message: "Images can be attached once you have saved the record for the first time."

I cannot use SimpleImageField because I want users to be able to browse the file store as well as upload images.

Ryan M.

Community Member, 309 Posts

19 January 2011 at 5:13pm

Edited: 19/01/2011 5:14pm

My advice would be to install Uploadify and use its ImageUploadField. It includes tabs to either upload new or select existing from file store.