Score:1

Allowing users to edit their webform submission

cd flag

I am using Drupal 8.9.17 and Webform 6.0.4.

I have created a webform (registering for an event) that I am attaching to nodes (events). On the webform, I have checked "Allow users to update a submission using a secure token." And I have limited users to 1 submission per source entity.

All is good so far, but I would like the "Per user submission limit message" to say "You have already registered for this event" and then provide a link to view and edit their submission. I have attempted to do this using the [webform_submission:token-update-url] token. And I set the permissions so that users can view and edit their submissions. However, the page for the URL that token spits out displays what appears to be an object defining the webform or submission (see below) rather than an editable form.

What do I need to do to get a link to an editable version of the user's previous submission?

[{"command":"settings","settings":{"pluralDelimiter":"\u0003","suppressDeprecationErrors":true,"ajaxPageState":{"libraries":"bartik\/messages,core\/drupal.dialog.ajax,webform\/webform.ajax,webform\/webform.element.details.save,webform\/webform.element.message,webform\/webform.theme.bartik,webform\/webform.theme.classy","theme":"bartik","theme_token":null},"ajaxTrustedUrl":{"form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM":true},"user":{"uid":"316","permissionsHash":"34761c7696a50fc1957b53a0440e5fbc76a45d32fd40b21730cd04235e14a2c2"}},"merge":true},{"command":"add_css","data":"\u003Clink rel=\u0022stylesheet\u0022 media=\u0022all\u0022 href=\u0022\/sites\/default\/files\/css\/css_FOOEWHqjLXy_O63myzh8hUcoZuIExqFZ0eRqKYy-9RI.css\u0022 \/\u003E\n\u003Clink rel=\u0022stylesheet\u0022 media=\u0022all\u0022 href=\u0022\/sites\/default\/files\/css\/css_lEZM4fAqordMuJ1-dXqK0bKq2L4VyJvN1PXENL6vMdE.css\u0022 \/\u003E\n\u003Clink rel=\u0022stylesheet\u0022 media=\u0022all\u0022 href=\u0022\/core\/themes\/bartik\/css\/components\/messages.css?qxmvlx\u0022 \/\u003E\n"},{"command":"insert","method":"append","selector":"body","data":"\u003Cscript src=\u0022\/sites\/default\/files\/js\/js_E9vyQmkm5LzBBPbbSIF-YmVm0fz-3tfjNa8_AFRwPRI.js\u0022\u003E\u003C\/script\u003E\n","settings":null},{"command":"openDialog","selector":"#drupal-modal","settings":null,"data":"\u003Cspan id=\u0022webform-submission-basic-registration-with-guest-op-node-220-form-ajax-content\u0022\u003E\u003C\/span\u003E\u003Cdiv id=\u0022webform-submission-basic-registration-with-guest-op-node-220-form-ajax\u0022 class=\u0022webform-ajax-form-wrapper\u0022 data-effect=\u0022fade\u0022 data-progress-type=\u0022throbber\u0022\u003E\u003Cform class=\u0022webform-submission-form webform-submission-add-form webform-submission-basic-registration-with-guest-op-form webform-submission-basic-registration-with-guest-op-add-form webform-submission-basic-registration-with-guest-op-node-220-form webform-submission-basic-registration-with-guest-op-node-220-add-form\u0022 data-drupal-selector=\u0022webform-submission-basic-registration-with-guest-op-node-220-add-form\u0022 action=\u0022\/form\/basic-registration-with-guest-op?source_entity_type=node\u0026amp;source_entity_id=220\u0026amp;_webform_dialog=1\u0026amp;token=WeB5W4FaolOq0x60yuzFjYhSG2f8Yr6uO42GRk2hi5M\u0022 method=\u0022post\u0022 id=\u0022webform-submission-basic-registration-with-guest-op-node-220-add-form\u0022 accept-charset=\u0022UTF-8\u0022\u003E\n  \n    \u003Cdiv data-drupal-selector=\u0022edit-0\u0022 class=\u0022webform-message js-webform-message js-form-wrapper form-wrapper\u0022 id=\u0022edit-0\u0022\u003E\u003Cdiv data-drupal-messages\u003E\n            \n      \u003Cdiv class=\u0022messages__wrapper layout-container\u0022\u003E\n                            \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Warning message\u0022 class=\u0022messages messages--warning\u0022\u003E\n                                          \u003Ch2 class=\u0022visually-hidden\u0022\u003EWarning message\u003C\/h2\u003E\n                                            You have already registered for this event.\u0026nbsp;http:\/\/skymallrats.com\/form\/basic-registration-with-guest-op?source_entity_type=node\u0026amp;source_entity_id=220\u0026amp;_webform_dialog=1\u0026amp;_wrapper_format=drupal_modal\u0026amp;token=zmHLhdHwo12LlVCmxhTREkEsusVfJLALFyO-TmaP69k\n                                      \u003C\/div\u003E\n                                  \u003C\/div\u003E\n      \u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cinput autocomplete=\u0022off\u0022 data-drupal-selector=\u0022form-1dpd8qhjutpnuhks0feh8riqxhsbx3ykzfl9cfyqlqm\u0022 type=\u0022hidden\u0022 name=\u0022form_build_id\u0022 value=\u0022form-1dPd8QHJutpNuHks0FEh8rIQXHsBx3ykzfl9CFYqLqM\u0022 \/\u003E\n\u003Cinput data-drupal-selector=\u0022edit-webform-submission-basic-registration-with-guest-op-node-220-add-form-form-token\u0022 type=\u0022hidden\u0022 name=\u0022form_token\u0022 value=\u0022U9CWc1vN1c9ZZwMc33PMeaUtyX-_AA52W5hEgx6tdt8\u0022 \/\u003E\n\u003Cinput data-drupal-selector=\u0022edit-webform-submission-basic-registration-with-guest-op-node-220-add-form\u0022 type=\u0022hidden\u0022 name=\u0022form_id\u0022 value=\u0022webform_submission_basic_registration_with_guest_op_node_220_add_form\u0022 \/\u003E\n\n\n  \n\u003C\/form\u003E\n\u003C\/div\u003E","dialogOptions":{"modal":true,"title":"Second Test Event: Basic Registration with Guest Option"}}]
misterdidi avatar
de flag
When you look at `/admin/people/permissions#module-webform` do your users have the permissions to view and edit their own webform submissions?
kosher avatar
cd flag
@misterdidi Yes, those permissions have been granted.
Score:0
fr flag

Just check "Limit users to one submission per webform/source entity" in the submission settings. Then:

Please make sure authenticated users are allowed to 'view own submission' and 'edit own submission'.

Now the user can submit their data. After submitting when they visit the webform again, they will see their previous data and can update that.

kosher avatar
cd flag
Everything you suggest, I indicated that I did in my initial question. And the result is that users cannot see their previous data, just the "Per user submission limit message" that I set up, minus the [webform_submission:token-update-url] token.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.