Problem/Motivation
When creating a node with a paragraph that references a webform, the variants functionality is not working.
After some debugging I noticed that the JS code that selects the variant is not added in that case. This is because \Drupal\webform\WebformRequest::getCurrentWebform()
doesn't find the current webform.
Steps to reproduce
* Enable paragaraphs.
* Create a paragraph type e.g. "Webform" and add an entity reference field to link webforms.
* Create a webform e.g. "Contact".
* Add the variant element and create 2 variants.
* Create a node and reference to your webform.
The node always shows the default variant and does not redirect or add a query param indicating which variant is used.
Comment | File | Size | Author |
---|---|---|---|
#6 | 3184177-7.patch | 6.95 KB | jrockowitz |
| |||
#5 | 3184177-5.patch | 6.39 KB | jrockowitz |
| |||
#3 | 3184177-3.patch | 5.5 KB | jrockowitz |
#2 | 3184177-2.patch | 2.91 KB | JeroenT |
|
Comments
Comment #2
JeroenTThe patch attached fixes the problem for me. The patch adds a check if the paragraphs module is enabled in
\Drupal\webform\WebformEntityReferenceManager::getWebforms()
. If that is the case, then this patch will check if one of the paragraphs is referencing a webform.Comment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe issue you're describing makes sense.
I refactored the patch a bit but I did not have time to replicate the issue and test the patch. I will try to do it tomorrow.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI was able to replicate this issue and the patch from #2 and #3 solve the problem. The only thing that is missing support webforms in paragraphs nested in paragraphs. We could have support recursively searching for webform inside paragraph field.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThis patch support webform in nested paragraphs.
@jeroent Does this patch address your variant use case?
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #7
JeroenT@jrockowitz,
I tried Patch #5 and it fixes my use case. Thanks!
Comment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented