Form in a block autofill by prev. submission values - documentation?

Created on 23 November 2021, about 3 years ago
Updated 28 May 2023, over 1 year ago

Problem/Motivation

Use case: webform in a sidebar block prepopulate/preserve submitted field values, if exist.

Steps to reproduce

I've poked around module configuration and there are a few places which seems "relevant":

- Webform Settings > Submissions > SUBMISSION AUTOFILL SETTINGS. Single checkbox, no configuration.

- Structure > Block Layout > Configure Block > Webform Settings > Default submission data (YAML)
Expects something like first_name: first_name: '[webform_submission:values:first_name]'

- Webform > Build > WEBFORM ELEMENT > Edit > Advanced > Default Value.
Expects a token(?) [webform_submission:values:first_name]

- Webform > Add Element > Value.
Expects [webform_submission:values:first_name] token.

- Webform > Add Element > Computed Token > Value.
Expects a token [webform_submission:values:first_name]

- Webform > Add Element > Computed Twig > Value.
Expects Twig {{ data.element_key }} (?) or
{{ webform_token('[webform_submission:values:first_name]', webform_submission, [], options) }} (???)

It looks like it works for stand-alone form and with SUBMISSION AUTOFILL SETTINGS checkbox.
Form in a block gives random results:
- sometimes it saves & uses submission values "per page", e.g. form values on, say, form submitted on node/1 differ from values submitted on node/2.
- sometimes form field values are empty after browser tab closed,
- sometimes tokens weren't replaced or submitted values left empty
- drush cache rebuild has no effect on this

Browsing the issue queue and Drupal Stackexchange has not been quite useful. Not sure this matter is being mentioned/covered in documentation/cookbook. Hence, a question if I may: what would be the right setup if we want to re-use the very first visitor's submission across all site pages? Would a hook_webform_something in a custom module be the best bet here, despite of all out-of-box settings available?

Haven't been worked with Drupal 9/Webform 6 before, it has been changed a lot comparing to its D7 counterpart!

✨ Feature request
Status

Closed: outdated

Version

6.1

Component

Documentation

Created by

πŸ‡ΈπŸ‡°Slovakia yurg

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024