Jump to:

23451 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Fix Please for Frustrating Image Upload Issue 3.1

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

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

Page: 1
Go to End
Author Topic: 310 Views
  • tazzydemon
    Avatar
    Community Member
    122 Posts

    Fix Please for Frustrating Image Upload Issue 3.1 Link to this post

    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

  • tazzydemon
    Avatar
    Community Member
    122 Posts

    Re: Fix Please for Frustrating Image Upload Issue 3.1 Link to this post

    This may well be mentioned in

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

    Although I cant see any difference in 3.1rc1

  • tazzydemon
    Avatar
    Community Member
    122 Posts

    Re: Fix Please for Frustrating Image Upload Issue 3.1 Link to this post

    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!

    310 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.