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

Fix Please for Frustrating Image Upload Issue 3.1


Go to End


3 Posts   762 Views

Avatar
tazzydemon

Community Member, 135 Posts

26 August 2013 at 11:09am

Edited: 26/08/2013 11:15am

Uncle Cheese's wonderful SS3.1 module silverstripe-gridfield-betterbuttons which furnishes "Save" "Save And..." and "Delete" still suffers from the confounding Silverstripe perplexity of the fact that you have to save the record first to make those buttons appear.

The purists will have it that until then the record does not exist. However to the average user, just uploading the image IS the record, nothing more, so a double action is illogical and unnecessary.

I decided that I would save the new image object the moment the upload field is instantiated. The fact that I will get left with empty object if the process is abandoned is far less confusing that the alternative.

This is from my SlideImage.php class which has a has_many on all page types (from Page.php)

$imageField = new UploadField('Image','Choose Images');
$imageField->setFolderName('Uploads/orbit-slider');
$imageField->setRecord($this);
$this->write();

The snag is that it doesn't work. It looks as though it's going to, but the write() makes the object vanish and then I get the classic can't handle suburls in the upload chooser when I choose from files.

So how does one do a an "autosave" properly upon instantiation of this form without the user knowing? It must be possible and I am sure many would want this. However this is where the form objects get very confusing and I need someone of Uncle Cheese's calibre to guide me!

Simple, effective and probably contrary to all the purists thinking but it means that the Uncle Cheese buttons "Save", "Save And..." and "Delete" appear immediately which is what Mr and Mrs Editor will expect.

Hope this helps

Avatar
tazzydemon

Community Member, 135 Posts

26 August 2013 at 11:51am

This may well be mentioned in

https://github.com/silverstripe/silverstripe-framework/pull/1862

Although I cant see any difference in 3.1rc1

Avatar
tazzydemon

Community Member, 135 Posts

26 August 2013 at 1:42pm

The use of https://github.com/colymba/GridFieldBulkEditingTools makes light of this issue though and to my amazement even gives me bulk edit of all the ancillary data that goes along with my images (like caption position and so on). I have to confess I would not have expected that to work out of the box!