When editing an existing node, or creating a new one:
- Upload a file
- Preview
- Check 'delete' for the file
- Preview -- The 'delete' checkbox is unchecked.
OR
- Save -- The file is still attached to the node.
Note that the behavior is different if you are editing a node with files already attached.
Also, the 'list' checkbox sometimes changes state seemingly at random.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | patch.txt | 4.55 KB | webernet |
| #9 | upload_checkboxes_preview.patch | 4.68 KB | quicksketch |
| #6 | upload_checkboxes_preview.patch | 4.49 KB | quicksketch |
| #4 | upload_checkboxes_preview.patch | 4.12 KB | quicksketch |
| #3 | upload_checkboxes_preview.patch | 4.56 KB | quicksketch |
Comments
Comment #1
quicksketchWhat's happening here is the data saved in $_SESSION is overwriting valid changes in the $form_state variable. If we had time remaining, the entire $_SESSION usage should be replaced with the FAPI cache instead, but alas. We'll be fine with it for now and remove it in D7.
This patch:
- Prevents the $_SESSION variables from overwriting changes in the $form_state (which maintains those checkboxes during preview).
- Adds a line to the upload_js() function to maintain the upload descriptions when making additional attachments via javascript.
- Add tabledrag.js() file to the new uploads form, not just the existing form. Previously tabledrag.js only was loaded if files have already been attached.
Comment #2
webernet commentedThis is an improvement, but it's not quite there yet.
Existing node with no files. Attach a file. Check delete. Preview. Delete is unchecked.
Also related - Reorder attachments. Preview. Attachments are in original order.
Comment #3
quicksketchArrrrrg.
This is a horrible mess. This patch corrects form ordering on preview. I still can't fix the attach -> preview problem. Though as webernet reports, it only happens on the first preview. I'll continue poking around to see if we can clear up this checkbox issue for D6.
This patch is written to change as little code as possible. Like I said above, to write this properly we really should eliminate use of $_SESSION entirely. Unfortunately my attempt at doing this was both long and bug-prone, so we'll likely be doing a 'just get it working' fix for D6.
Comment #4
quicksketchUsing #default_value instead of #value seems to be the trick. It makes me feel better using #default_ anyway, and now we're saving the new default into the form cache every update.
This patch changes less code, is much cleaner, and fixes all the problems I could possibly find concerning upload module's problems with Preview and AHAH requests. Webernet, want to give it a shot?
Comment #5
webernet commentedTested and the checkboxes and weights appear to be working fine.
This does however introduce a number of notices: Attach. Save. Edit. Attach. Notices!
I also noticed that with the patch, clicking the upload button without a file selected causes some weird behavior.
Comment #6
quicksketchThanks webernet for the good review. I thought I tried everything ;)
I had removed from is_numeric() checks, which seems like they were necessary for the empty upload case. It's better now. Those notices were pretty important it turns out, as it would eat your attachments if you resaved the node after editing.
This patch should correct these two issues.
Comment #7
webernet commentedTested OK, and I think the patch is probably OK as is.
I did find another minor related bug though -- New node. Don't set a title. Attach. Preview.
Without patch - file is lost. With patch - file is included, but fieldset is closed, and table of attached files is below the attach button rather than above it.
Comment #8
quicksketchAh! I knew this happened somehow. I did it once but didn't pay attention to the steps. We can fix this problem too. Patch coming forthwith.
Comment #9
quicksketchThis patch does 2 more things:
- Expands the fieldset in the form cache if an AHAH upload is made.
- Puts a weight on the upload field so that it is always below the list of uploads.
This patch intentionally has one very minor quirk: New node -> click upload without selecting file -> Preview. The Attachments fieldset is still expanded. This could be fixed with an additional variable and an IF statement, but the bug is so incredibly minor I don't think it's worth even the 4 lines of code.
Comment #10
webernet commentedTested OK - made one minor change since I don't think it's worthwhile expanding the fieldset when there's a missing title.
Otherwise this is ready to go.
Comment #11
gábor hojtsyThanks, committed.
Comment #12
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.