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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JeroenT created an issue. See original summary.

JeroenT’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.91 KB

The 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.

jrockowitz’s picture

The 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.

jrockowitz’s picture

I 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.

jrockowitz’s picture

This patch support webform in nested paragraphs.

@jeroent Does this patch address your variant use case?

jrockowitz’s picture

JeroenT’s picture

@jrockowitz,

I tried Patch #5 and it fixes my use case. Thanks!

  • jrockowitz authored 8baae5e on 8.x-5.x
    Issue #3184177 by jrockowitz, JeroenT: Webform Variants not working in...
jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz authored 8baae5e on 6.x
    Issue #3184177 by jrockowitz, JeroenT: Webform Variants not working in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.