When a reference field to a webform is used in a paragraph type, the submitted to field is not filled in on submission.

This is because the paragraph entity is used and not the parent node entity.

The paragraph entity can be examined to get the underlying node entity so the field is populated properly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

John Cook created an issue. See original summary.

John Cook’s picture

I've created a patch to traverse the entity tree until a non-paragraph entity is found and use that as the source entity.

The result is shown below:

John Cook’s picture

Status: Active » Needs review
jrockowitz’s picture

Did you try to uncheck "Use this field's Content entity as the webform submission's source entity."?

I know this setting is hidden but I think it solves your problem.

jrockowitz’s picture

Status: Needs review » Postponed (maintainer needs more info)
John Cook’s picture

@jrockowitz

Thanks, unchecking the checkbox works when viewing the node's page. But if viewing the node using other methods (views for example) there isn't an entity from the URL that can be set.

Having the checkbox checked and applying the patch in #2 allows the node to be set, even when using views to show the nodes. I think this would be the required behaviour.

On the other hand, the description text says:

Use this field's Paragraph entity as the webform submission's source entity.

If the patch in #2 is to be used, then an exception for this text needs to be created as well.

  • jrockowitz committed 6676f7a on 8.x-5.x authored by John Cook
    Issue #3000984 by John Cook, jrockowitz: "Submitted To" field not...
jrockowitz’s picture

Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Needs review

@John Cook I am 100% onboard with this patch.

Can you please update the description text to use the paragraph's parent source entity?

You could add a WebformEntityReferenceEntityFormatter::getSourceEntity() helper method.

Finally, there needs to be a very brief change record since the expected behavior is changing?

  • jrockowitz committed 9fc13fd on 8.x-5.x
    Revert "Issue #3000984 by John Cook, jrockowitz: "Submitted To" field...
jrockowitz’s picture

The patch from #3001446: Access denied message is not being displayed updated WebformEntityReferenceEntityFormatter::viewElements so I re-rolled this patch. I also changed the WebformEntityReferenceEntityFormatter::settingsForm title and description to use the below text.

Use this paragraph field's main entity as the webform submission's source entity.
If unchecked, the current page's entity will be used as the webform submission's source entity.

I am not sure how to address Webform fields that are displayed as links. Still, this patch is already addressing a major problem with paragraphs integration.

jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch.

We can resolve how to handle a webform field displayed as a link within a paragraph in a new ticket.

Status: Fixed » Closed (fixed)

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

jrockowitz’s picture

Status: Closed (fixed) » Needs work
FileSize
5.41 KB

Wow! I completely failed to apply this patch.

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
6.36 KB

Status: Needs review » Needs work

The last submitted patch, 14: 3000984-15.patch, failed testing. View results

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
7.51 KB

  • jrockowitz committed 41f0a9e on 8.x-5.x
    Issue #3000984 by jrockowitz, John Cook: "Submitted To" field not...
jrockowitz’s picture

Status: Needs review » Fixed

BTW, I did figure out how to handle a webform field displayed as a link within a paragraph.

  • jrockowitz committed d91535c on 8.x-5.x
    Issue #3000984 by jrockowitz, John Cook: "Submitted To" field not...

Status: Fixed » Closed (fixed)

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