Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[2012-09-30] Files uploaded during modeladmin "add new" process should create the appropriate relationship. #1606

Closed
silverstripe-issues opened this Issue · 4 comments

4 participants

@silverstripe-issues

created by: camfindlay
created at: 2012-09-30
original ticket: http://open.silverstripe.org/ticket/7917


From a dev POV I understand that I cannot create a relationship between a DataObject and a related File... an example may be a product with a $has_one Image. However the user experience with the modeladmin interface needs some work.

Currently I have to first add the DataObject (say a Product), if I attempt to add an image at the same time the image still uploaded but the relationship gets lost.

At this point I am unsure how we would achieve this but it would make a lot of sense for the fact that an image has been attached during the create process to be stored and to somehow create this relationship once the write process for the DataObject is complete(an actual ID for the item would then exist).

Explaining to clients that what should really be a quick easy one step process to get their content online is actually a 2 step process kinda sucks and there is potential for lost content especially if someone is loading a lot of content or doing a migration over to SS from another system.

@silverstripe-issues

comment by: camfindlay
created at: 2012-09-30


Another community member also brought this up on the forums:

http://www.silverstripe.org/customising-the-cms/show/20999

@joelpittet

+1 this issue is a huge UX drawback.

From a potential workflow could be that a status flag for later cleanup? Or at the very least just allow unassociated file uploads, and if the record save fails the file just exists within the library 'unattached'.

@chillu
Owner

Agreed, this should be technically possible - with the caveat that files will stick around if the record creation process is aborted (or fails due to validation). That should be configurable behaviour in UploadField (suggestion: canUploadBeforeCreate).

@raket I think your solution in raket@31dc8be is pretty close, but it would be great if we can make the serialization more future proof by defaulting to a parameter array. So MyUploadField[]=<first-file-id>&MyUploadField[]=<second-file-id> instead of MyUploadFieldID=<first-file-id>. Also, have you tested that it correctly re-loads uploaded files after submitting the form with a validation error?

C'mon guys, we're so close, is somebody keen to get this over the line? :)

@Zauberfisch

the issue that the file relation is lost is actually a bug.

I haven't searched for the source of this bug, but I know how to work around it.
somehow the upload field does not find the record at that point, because if it found it, it would say "you have to save first, before you can add files"

I explained the work around in a comment on issue #1600

once the work around is applied, UploadField will tell you to save before you can add files.

@chillu chillu closed this
@chillu chillu reopened this
@chillu chillu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.