Once one has added an asset -- as an Asset field type -- to a CCK-based content node, the "Delete Asset" functionality does not work. Upon clicking the icon, the fields all clear and the preview image vanishes, but upon submitting the form, the asset is not actually deleted (i.e. detached from the node -- not physically deleted from the server).
In other words once you've added an asset (as a field type) to a node, you're stuck with it forever. You can change which asset is selected, but you can't actually detach it from the node.
Curiously, this does not seem to occur if the field type is set to allow multiples. In that instance it's worked as expected for me (so far). Additionally, the field containing the filename is readonly, whereas when it's a non-"multiple" field type it is writable.
Repro
1. Create a new content type via CCK.
2. Add an "Asset" field type (along with whatever else). Do not set as allowing "Multiple".
3. Create a new node using the content type. Add an Asset. Save it.
4. Edit the new node. Click the asset's "Delete Asset" icon (file icon with red minus). The relevant fields and image preview will clear as expected.
5. Save the edit.
6. Go back to edit the same node. The "deleted" assets is still there.
Confirmed in Firefox 2.0.0.14 (Windows), Firefox 2.0.0.11 (Mac), and IE 7.
Comments
Comment #1
wmostrey commentedAnd you're experiencing this with beta3? I'm not able to replicate this really. What label do you give your field? Do you have this for labels with a space in them? And without a space in them? Do you get a javascript error?
Comment #2
wmostrey commentedI see this now, this issue happens both when a label has a space or no space in the filename, so that's unrelated. I'm on it.
Comment #3
spencersundell commented@wmostrey
I see you've already followed up somewhat on your questions, but just to answer you:
Thanks again...
Comment #4
janwari commentedIm using beta3 and im facing the same issue with Asset fields. Once an image is attached to a story its not possible to delete it unless you go into the db and manually delete that asset id relating to that particular node.
I spent an hour trying to figure out what was the cause of not being able to delete the assets. Initially I suspected that it must be something on the client side where some of the DOM elements attributes were not cleared which must have caused for the element to persist on the page. So using FF's DOM Inspector I found out all the elements containing the variables and manually tried to clear them all.
I tried to clear all the attributes containing the image name and then save the node and again check it to see if the asset was deleted.
document.getElementById('edit-field-feature-image-0-caption').defaultValue='';
document.getElementById('edit-field-feature-image-0-caption').value='';
document.getElementById('edit-field-feature-image-0-caption').innerHTML='';
document.getElementById('edit-field-feature-image-0-caption').textContent='';
document.getElementById('edit-field-feature-image-0-value').defaultValue='';
document.getElementById('edit-field-feature-image-0-value').value='';
document.getElementById('preview_field_feature_image_0').innerHTML='';
Unfortunately the asset wasn't deleted which leaves me wondering that something has to be happening on the server side(i.e Drupal hooks) where its using the pre-cached value before the asset was deleted.
Hoping for a patch.
Comment #5
wmostrey commentedThis has been fixed in the latest dev version and is included in beta4: http://drupal.org/cvs?commit=117088
Comment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.