Unable to update a webform submission using paragraphs and update tokens

Created on 26 December 2022, over 2 years ago
Updated 22 February 2023, over 2 years ago

Problem/Motivation

The webform submission is not loaded using paragrahs.

Steps to reproduce

  • Create a new paragraph type and add a webform field
  • In the display mode ensure you enable: "Use this paragraph field's main entity as the webform submission's source entity."
  • Create a submissions
  • Try to update the previous submission using the update token

The problem is that in the src/WebformSubmissionForm.php we are replacing the pragraph by the main source entity.

    // Get the source entity and allow webform submission to be used as a source
    // entity.
    $source_entity = $entity->getSourceEntity(TRUE) ?: $this->requestHandler->getCurrentSourceEntity(['webform']);
    if ($source_entity === $entity) {
      $source_entity = $this->requestHandler->getCurrentSourceEntity(['webform', 'webform_submission']);
    }
    // Handle paragraph source entity.
    if ($source_entity && $source_entity->getEntityTypeId() === 'paragraph') {
      // Disable :clear suffix to prevent webform tokens from being removed.
      $data = $this->tokenManager->replace($data, $source_entity, [], ['suffixes' => ['clear' => FALSE]], $this->bubbleableMetadata);
      $source_entity = WebformSourceEntityManager::getMainSourceEntity($source_entity);
    }
    // Set source entity.
    $this->sourceEntity = $source_entity;

So the previous webform submission can't be loaded.

πŸ› Bug report
Status

Needs work

Version

6.1

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain facine

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