i have a field collection of multiple values that contains an image and a text, if i select an image without clicking "Upload" then i click on "Add another item" the image is not uploaded, instead the field appears empty, i think this is a big usability issue .

Comments

Pepe Roni’s picture

This is not a problem with field collection but with understanding how the web and browsers work. If you select an image *to upload* it is not uploaded directly but marked for upload. If you do not upload it, it will not be uploaded (same happens with "bare" image field in a node if you select the image and then save the node). Image upload is always this two phase process: select the image and then upload the selected image.

josebc’s picture

if you select an image and save the node in a normal image field, the image will be uploaded automatically, you dont need to hit the upload button then save the node ... a normal web user will expect for the form to hold its values when adding another item (in the case of field collection) , not re-selecting the images.

Anonymous’s picture

There is a confusing difference in behaviour here.

With a regular image field on a content type (multiple values allowed), the user can only choose a second, third etc file once they have clicked the upload button for the previous files. So the process is linear and clearly defined.

With Field Collection, the "Add another item" button is always there at the bottom even when no image has been specified.

Another issue I have with the "Add another item" button is that the position of the form doesn't get remembered which is very disorientating for the user who has to scroll back to the place they were. I'm not sure whether this is a consequence of the entire form reloading when the button is pressed.

.kuma’s picture

I agree with josebc that the form values should be saved.

Here's a workaround I'm using that auto-uploads a file after selecting, thus the issue is never encountered:
http://drupal.stackexchange.com/questions/31121/how-can-i-automatically-...

Not a true solution however since it's forcing an upload, which may be inconsistent with other forms on your site (depending how you implement); would be nice for the module to retain the selected file without the need for upload.

svefre’s picture

I've just found the "AutoUpload" module (https://drupal.org/project/autoupload), it works perfectly fine. The upload button isn't visible anymore, and when you're finished selecting an image from your hard drive the upload happens instantly.

jmuzz’s picture

Priority: Major » Normal
Issue summary: View changes
ladybug_3777’s picture

I just stumbled upon this issue yesterday. I agree, it seems like it should save the selected file or at least do an auto upload when you add another field collection item.

Right now we are training our content editors to make sure they always click "upload" so the selected image isn't lost, but from a content editor perspective it is odd to see the image input fields behave a little differently.

I'll take a look at that autoupload module and see how that works, thank you for mentioning it as an option. I'll also see if I can provide a patch to upload any selected files when "Add another item" is clicked as that seems more like what we would want field collection to do on it's own anyway.

ladybug_3777’s picture

Also, for anyone that may be wondering, this issue (as expected) also effects file fields, not just image fields.

jmuzz’s picture

File is a core module so it should be properly supported by field collection. I would be in favor of disabling the add another button when there is an un-uploaded file there.

A bit of explanation and a warning about automatically uploading files:

The reason browsers operate with a 2 step process is because it is possible that a user may accidentally choose the incorrect file in their browser. It may even be a file containing sensitive information, so there are security concerns if planning to force them to upload the file and save it on your server at that point.

It's true that the image is automatically uploaded when a user submits the node form, but clicking submit is a confirmation that the user chose the values they intended. A user clicking "Add another" on the other hand, doesn't tell us that the values there are what they want, so their files shouldn't be uploaded automatically at that point.

ladybug_3777’s picture

I agree jmuzz and you point out a very valid example of accidentally uploading sensitive material. Another issue that came to mind is you may end up with a lot of extra "junk" files on your server when using an automated upload process. Someone may start to work on a node, upload a bunch of images and or files, and then decide they don't actually want to save the node and they bail. However, with auto upload, all of those un-needed files now live on the server taking up space.

ladybug_3777’s picture

So I've spent some time poking around in the field collection code and I have to admit, I'm unsure of how to properly tackle this problem. I think jmuzz's idea of simply disabling the "Add Another Item" button is the best approach, but I'm having some difficulty figuring out how to work that in.

There's a lot of logic to sort through so while I'm still looking into it, I don't expect to be able to produce a solid patch any time soon.