Hi

Love the module, still new to it, but tried everything i can think of

Whenever i attach a file to a node and preview the node, the "reference" is lost. The only way I've managed to attach files is by saving directly (the submit button)

I've had this problem previously with the regular upload module, but it works flawlessly now.

I'm using version 5.*.2.13 which I couldn't select in the "project information fieldset"
Any help on this would be appreciated.
Please ask if you need more info
- holbech

CommentFileSizeAuthor
#4 webfm.preview.patch8.34 KBFrank Steiner

Comments

dwbm’s picture

I 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.

Anonymous’s picture

I see the same problem in 6.x.

Anonymous’s picture

Version: 5.x-2.9 » 6.x-2.9-alpha2
Assigned: Unassigned » Frank Steiner

I'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.

Anonymous’s picture

Title: Attaching files fails when previewing » webfm support for previews
Component: Miscellaneous » Code
Status: Active » Needs review
StatusFileSize
new8.34 KB

Here'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:

  • We must keep attachments through a failed preview (failed form_validate).

    Just use default_value instead of value for 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.

  • We must keep attachments through a successful preview.

    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.

  • We must show the table in the preview (if configured). Here we can use $_POST['attachlist'] in nodeapi('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.
robmilne’s picture

Status: Needs review » Fixed

see 6.x-2.10-rc1

Anonymous’s picture

Status: Fixed » Closed (fixed)

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