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.

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

3.4 Image UploadField Oddity (FIXED)


Go to End


3 Posts   695 Views

Avatar
tazzydemon

Community Member, 135 Posts

28 July 2016 at 10:14am

Edited: 30/08/2016 5:02pm

I was using the UploadField like this

        $imageField =  new UploadField('Image','Choose Image');
        $imageField->setFolderName('Uploads/promotionalbanners');
        $imageField->setRecord($this);

Now in 3.4 it has to be:

        $imageField =  new UploadField('Image','Choose Image');
        $imageField->setDisplayFolderName('Uploads/promotionalbanners');  
          //set where a new one is chosen from in tree dropdown .
        $imageField->setFolderName('Uploads/promotionalbanners'); 
          //set where images are actually uploaded to
        $imageField->setRecord($this);

Prior to 3.4 when one tried to choose "From File" or "Choose Another File" the resultant dialogue box would be open in the right place, in this case Uploads/promotionalbanners. However when a new file is dropped in there it is correctly saved to Uploads/promotionalbanners so the code is partly working

I have been using this code since 3.1 - years and it has always worked perfectly until now. What has happened?

On 30 August I found that one has to set ones field like this:

<code> $imageField->setDisplayFolderName('Uploads/promotionalbanners');</code>

Research then showed that Chillu has requested a pull ages ago with this in it. https://github.com/silverstripe/silverstripe-framework/pull/2064
This only seems to have reared its ugly head in 3.4 (maybe 3.3 too)

Avatar
Dobby

Community Member, 15 Posts

26 August 2016 at 10:21am

Any news here?
I have the same problem. What was changed here?

Avatar
tazzydemon

Community Member, 135 Posts

30 August 2016 at 4:46pm

Fixed it. See first post