How to embed webform to update existing submission I'm trying to display a webform through a module controller. The webform display works as it should but I need to update existing submission data and instead of updating the existing submission a new one gets created.

The code I use looks like this:

public function edit()
{
  $submissionId = \Drupal::request()-&gt;get('sid');
  $webform = Webform::load('eventsignup');
  $webformSubmission = WebformSubmission::load($submissionId);
  $webform = $webform-&gt;getSubmissionForm([
    'data' =&gt; $webformSubmission-&gt;getData()
  ]);

  $build['submissionForm'] = $webform;

  return $build;
}


I tried to alter it by giving the operation "edit" and setting the "sid" but that leads to a duplicate key error:

public function edit()
{
  $submissionId = \Drupal::request()-&gt;get('sid');

  $webform = Webform::load('eventsignup');
  $webformSubmission = WebformSubmission::load($submissionId);
  $webform = $webform-&gt;getSubmissionForm([
    'sid' =&gt; $submissionId,
    'data' =&gt; $webformSubmission-&gt;getData()
  ], 'edit');

  $build['submissionForm'] = $webform;

  return $build;
}


What am I doing wrong?

Thanks for your help!
Existing webform submissions are entities and you can use the entity form builder service to build the form:

// load the webform submission entity
$webformSubmission = WebformSubmission::load($submissionId);
// build a form for the entity
$webform = \Drupal::service('entity.form_builder')-&gt;getForm($webformSubmission, 'edit');