Steps to reproduce:
1) Install drupal 6.14,
2) Install and enable cck 6.x-2.6, filefield 6.x-3.2
3) Create new cck-field for the Story nodetype: Field name: "test_file", Field type: "File"
4) Create new node of the Story nodetype. Set title to "AAAAA". Upload a file
into the test_file field. Click Save button
5) Return to node edit form
6) Change node title to "BBBBB". Place cursor into the Title field and hit Enter button
Expected result:
The node view page should be opened with message "Story BBBBB has been updated."
Actual result:
Edit node page gets presented with empty test_file field and title set to "BBBBB".
After reloading page (by clicking on Edit tab or hitting F5) you see the old state of the
story: title set to "AAAAA" and uploaded file in place
Comments
Comment #1
dan.nsk commentedFurther information on this bug
1) If Story nodetype has several file fields (or one field with several files
attached) only the first file gets cleared after submitting the form on Enter key.
2) This behaviour is not browser dependent. It is the same for FF, IE and Opera
Comment #2
dan.nsk commentedThis problem is caused by the fact that the FileField module adds custom submit
buttons to the node edit form. These are Upload file and Delete file buttons.
When a user presses Enter key on a text input field, browser treats this situation
like if the first submit encountered on the form was clicked.
With no FileField installed, the first submit button on the node edit form is
"Save node". But when FileField is installed and a file is uploaded,
"Delete file" becomes the first submit button.
The only way I found to avoid this is to use the following js code:
This is not the ultimate solution, of course. Perhaps someone could suggest a
more simple way to avoid such a weird behaviour.
Comment #3
wardazo commentedI think it's a great fix! Saved me hours.
But just to clarify in case anyone else has to fix this bug if you make a file called fix.js in your template file:
and then in your template info file
It's easier to implement. This isn't directed to the original poster but rather anyone else who has this problem and is unsure about how to deal with implementing jquery in Drupal.
Again to the original poster - thank you!
[This is obviously not meant as a real solution to the bug - just a work around]
Comment #4
drupalido commentedI´ve got the same problem with the VIEWS formular where I want to show thumbnails of uploaded youtube videos (over filefield) but after saving the view it shows "DEFAULT" and not "Thumbnails" in the Format Area of the View.
Any Solutions??
Comment #5
quicksketchdrupalido: Your comment does not apply to this issue. This is an issue with the node form and has nothing to do with Views. I answered in your other issue #755644: Format and Label error in Views.
Comment #6
quicksketchThis is not a bug in FileField, it's simply the normal behavior of HTML. If you want to disable the return key on textfields see these other issues or do some research on how you can disable the return key within textfields:
#348747: Automatically tab between fields instead of submitting on Enter key
#212423: Standardize form submission behavior when "enter" key is pressed
Comment #7
srinivasan.raj84 commentedThis fix worked for me. enter key triggers the node save button and the uploaded file saved without any problem. Below is slight modified version
if (Drupal.jsEnabled) {
$(document).ready(function(){
var items = $('#node-form input');
$(items).keydown(function(event){
if (event.keyCode == 13) {
$("#node-form #edit-submit").click();
return false;
}
});
});
}