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.

Widgets /

Discuss SilverStripe Widgets.

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

Slideshow widget


Reply


10 Posts   4634 Views

Avatar
jpmcc

Community Member, 14 Posts

10 November 2011 at 6:34am

This is exactly what I was looking for. Just a few tweaks:

$options = array();

I changed to :

$options = '<option value="0">Please select an image</option>';

to provide an empty selection, otherwise the first image is already selected, and if it was saved, potentially the wrong image would be saved.

Also just to note that when adding the field to the widget, the image field ID should be specified, so if:

//My Widget

static $has_one = array(
'MyWidgetImage' => 'Image'
);

//when adding the field

$widgetImageField = new WidgetImageField('MyWidgetImageID', 'My Widget Image');

Cheers for sharing this!

Avatar
bartvanirsel

Community Member, 94 Posts

20 January 2012 at 10:11pm

thanks! old topic but it really helped me out!