1/ Make sure "multiple values" is disabled
2/ Upload a file. The filename is now entered in the description field
3/ Upload a new file. The description field remains the old filename and is not updated to the new filename

Comments

brunodbo’s picture

I'm having a similar problem: when I upload a file and change the description to something different than the file name, the description is not updated. Instead, it's still showing the file name.

For instance, when I upload a file called 'foo.pdf', that file name is displayed, even though I entered 'lala' in the description field.

jpetso’s picture

Status: Active » Postponed (maintainer needs more info)

Can you verify that bug for the 2.x release, please? No idea if it's still in there.

ivrh’s picture

Version: 5.x-1.x-dev » 5.x-2.2
Component: Documentation » User interface

I am using version 2.2 and this bug is there.
Moreover, when I edit created node and change description field to something I want to be displayed - it works, but I need to edit the node again. When creating a new node with file upload field - it fills "Description" field with filename, no matter if I enter "Description" manually (it just ignores my input). Editing the node fixes it.

ivrh’s picture

IT WORKED FINE WHEN AJAX UPLOAD FAILED.

Something failed with AJAX file upload and it caused page refresh to upload a file. When the node was submitted - Description was in place instead of usual filename. So, I presume this is AJAX or session variables (or both - depending of now the Description and filenames are stored temporarily).

jpetso’s picture

Thanks for testing, the status can now be pushed back to 'active' again. Let's see when I can find time to get this fixed.

jpetso’s picture

Status: Postponed (maintainer needs more info) » Active

Arr! Didn't I want to change the status? ...

dopry’s picture

This bug only seems to happen with ajax uploads disabled on single value fields... I have a feeling the #default_value doesn't want to get updated. It doesn't really both me as I do ajax only sites in general....

Any one got this itch to scratch? I'd like to see it closed before I release 2.3.

jpetso’s picture

You're right, it seems like Form API plays a trick on us again. #default_value is being written correctly the second time as well, but seems to be overridden by the value that has been "entered" when uploading the previous file. Let's see if I can figure out a remotely clean fix for this...

jpetso’s picture

Status: Active » Needs review
StatusFileSize
new2.46 KB

Yo, I did it.
dopry, please review the attached patch and see if it's ok from the coding point of view.
Remaining audience, please apply the patch on your filefield and tell me if it fixes the issue for you.

Hope you like it!

jpetso’s picture

StatusFileSize
new2.46 KB

Better patch, using the file path for comparison, not its name. (Using the file name was a remainder of comparing with the description, which I also tried.)

dopry’s picture

Status: Needs review » Reviewed & tested by the community

Looks good a little byzantine to keep a text field sane, but oh well it does the job... but commit that when you feel like it... I'll try to get around to commits in a couple days, but I'm in mid travelling at the moment.

jpetso’s picture

Well, byzantine... looking at form.inc, I couldn't see any way to enforce the '#default_value' being displayed instead of the submitted value. So we would either need something like the above patch, or change the form element name from 'upload' to something that is unique for each newly uploaded file - which has the potential to be cleaner, but also needs extra code (in other places).

I didn't commit it before because I wasn't sure if you like the above approach... if it's not clean enough, I can also try out if the other one is doable.

dopry’s picture

no whats there is fine.. :)

dopry’s picture

committed to DRUPAL-5--2

dopry’s picture

Status: Reviewed & tested by the community » Fixed

committed to DRUPAL-5--2

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.