Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
silverstripe-issues opened this issue Apr 3, 2013 · 4 comments

Comments

@silverstripe-issues
Copy link

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
Copy link
Author

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
Copy link

+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
Copy link
Member

chillu commented Apr 26, 2013

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants