Score:0

How to create a new submission from a previous submission?

cn flag

Currently, when I submit a new form, there is no problem (WebFormSubmission::create() and save()). When I reload this Webform submission and modify some fields of form and record it, there is no problem (WebformSubmission::load() and save()).

But I not able to create a new Webform submission from this previous Webform submission. Aim is to have 2 independant submissions.

I tried to create() and save() after moditication but something is wrong.

No Sssweat avatar
ua flag
Welcome to Drupal Answers. You said, `but something is wrong`. You'll need to be more specific than that, what error are you getting? Also, we'll need to see your code.
cn flag
It sounds like you want to duplicate the submission? I don't relate to your use case for something like that but you could look into the "entity clone" module. It adds a clone operation to entities, and a webform submission is a content entity in and of itself.
apaderno avatar
us flag
Welcome to Drupal Answers! This question seems about code you wrote. In this case, as @NoSssweat said, we need to see the code you wrote. If the question isn't about code, please edit it to make that clear and to add more details that allow us to answer it.
Score:0
us flag

In the Webform UI, you are able to duplicate submission via the results table submission operations.

Via the Webform APIs, you can use \Drupal\webform\Entity\WebformSubmission::createDuplicate.

erwan1974 avatar
cn flag
Great!!! I use Webform APIs and I obtain a new submission without problem. Thanks
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.