Store a static reference to file in results

Created on 24 May 2024, 6 months ago
Updated 19 August 2024, 3 months ago

This module seems to work great, thank you for creating it.

Seeing as our file changes version regularly enough, I'd like to be able to store the filename in the results table at submission time.

It seems that the [webform_submission:protected_download_url] token is only available post-submission and gets stored as a string when entered into e.g a hidden field.

I've also tried a few combinations of [webform:handler:?] however have not got anything to work.

I realise this may require something custom yet, to grab the filename from somewhere and insert it into the results at submission time, but thought I'd ask the question first in case there's a simple answer.

Thank you.

✨ Feature request
Status

Active

Version

2.0

Component

Miscellaneous

Created by

πŸ‡¬πŸ‡§United Kingdom kiwimind

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kiwimind
  • πŸ‡¬πŸ‡§United Kingdom james.williams

    Thanks, good question ... I don't believe this is currently possible, as yes, the token is currently only available once the submission exists - which is after hidden fields are built or populated. So at the moment custom code would be necessary. But if you or anyone else wants to have a go at implementing this ability into the module codebase, I can see the value and would accept it & help with getting it in place! It wouldn't necessarily need to use tokens either; fundamentally you just want to be able to reference the file that was available at the time of submission, so that when the file or handler config changes, the reference or value in the submission is unchanged.

  • πŸ‡¬πŸ‡§United Kingdom kiwimind

    Thanks very much for the prompt response.

    I'll have a think about this. If there's time on this project then I may well have a crack, otherwise we may have to rely on revisions by date.

  • πŸ‡ΊπŸ‡ΈUnited States devkinetic

    Maybe instead of adding the file in the handler directly, we could leverage media via a reference field, and then grab the file how file_download_link does.

  • πŸ‡¬πŸ‡§United Kingdom james.williams

    @devkinetic using a file field on a media entity (or similar) means the file is actually publicly accessible at a specific URL, plus one of the fundamental features of webform_protected_downloads is that the files can be uploaded by admins as part of the webform config itself rather than needing to set up things elsewhere first. (see the comparison of similar modules β†’ .)

    So I'd be reluctant to head in that direction, unless mitigation for those two things can be made alongside any such change.

Production build 0.71.5 2024