Closed (fixed)
Project:
Web File Manager
Version:
6.x-2.9-alpha2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
22 Apr 2008 at 15:31 UTC
Updated:
29 Oct 2008 at 18:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dwbm commentedI just wanted to say that I am having the exact same problem... which is a big deal because I require users to preview before submitting.
Otherwise - awesome module.
Comment #2
Anonymous (not verified) commentedI see the same problem in 6.x.
Comment #3
Anonymous (not verified) commentedI'm working on a patch for 6.x. It does already keep webfm attachments during preview and failed form_validates, but it does not yet display the attachments in the preview. I will have to check how the upload module does this and see if I can port it. I will post the patch in a few days, and as it is quite short, I guess it should be easy to backport to 5.x.
Comment #4
Anonymous (not verified) commentedHere's a first try. It's not that large and I will try to explain what I did so that someone using 5.x should be able to backport it.
Note that webfm didn't only remove the file references when previewing, but also when the user clicked on "save" but form_validate failed (e.g. because you forgot the title of the node). I didn't write a seperate patch to fix only that behaviour because it would be almost identical with the preview patch.
Here's what needs to be considered for a preview functionality:
Just use
default_valueinstead ofvaluefor the hidden form elemente storing the attachment fids. This will keep the value during a form rebuild in a failed as well as in a successful preview.In a failed preview, we must reinitialize webfm in
nodeapi('validate'), otherwise no javascript code will be loaded and the webfm menu in the form will no longer work. That's because the initialization is done in form_alter which is not re-executed if form_validate fails.When an edit form is first loaded, webfm reads the attachment list from the database, adds them to the hidden form element one by one, and displays them in the webfm menu of the edit form.
Whenever a submit is successful (preview button or save button), the attachment list can be found in
$_POST['attachlist']. In a preview, we just refill those values into the hidden element of the edit-form and make sure that webfm reads the values from there when building the webfm menu.The webfm menu is built by javascript code in webfmjs. In Webfm.attach.prototype.fetch we fetch the fids from the hidden form and transfere them to webfm_ajax by an additional parameter. In webfm_ajax we just check for that parameter and use the stored fids instead of reading the database to build the table.
$_POST['attachlist']innodeapi('view')but we must decide if we are viewing or previewing the node. See the comments in the patch, they explain this in more detail.Comment #5
robmilne commentedsee 6.x-2.10-rc1
Comment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.