Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using the webform API in a custom controller, I need to save a draft with another webform_submission
as its source entity.
However the current code seems to be designed with the assumption that a draft cannot have a webform_submission
as a source entity.
As seen in WebformSubmissionForm::setEntity():
$this->sourceEntity = $this->requestHandler->getCurrentSourceEntity(['webform', 'webform_submission']);
if I remove webform_submission
as a filter I'm able to load a draft.
I can understand why it is filtering the webform
entity but is there a reason why this code is filtering for webform_submission
?
Comment | File | Size | Author |
---|---|---|---|
#16 | draft_with-2854714-15.patch | 3.15 KB | jrockowitz |
| |||
#13 | draft_with-2854714-13.patch | 2.74 KB | jrockowitz |
#10 | draft_with-2854714-10.patch | 2.67 KB | jrockowitz |
#2 | draft_filter_webform_submission-2854714-2.patch | 806 bytes | ptsimard |
Comments
Comment #2
ptsimard CreditAttribution: ptsimard commentedHere is a patch that fixes the issue for me. Hopefully this passes all the tests?
Comment #3
ptsimard CreditAttribution: ptsimard commentedComment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedOriginally, I was trying to avoid having a webform or submission become the source entity.
I think the source entity filtering needs to be reworked. I might need make it possible to set the available source entities as an advance setting.
For example in #2853870: Limit User Per Entity Submission: Does not work when Webform is Attached to a Submission, the webform submission needs to be source entity, instead of the attached webform node.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am vacation for the rest of the week but I am going to add some notes here.
Tasks
@ptsimard if your patch works for your setup, you should be okay using it, until I get fully working and integrated solution.
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think this might be opportunity to move all source entity related webform settings into a dedicated details element which could include more documentation.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #16
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download and review the latest dev release.
Comment #19
ptsimard CreditAttribution: ptsimard commentedSeems to be working for me thanks!