Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#16 | 3000984-16.patch | 7.51 KB | jrockowitz |
| |||
#14 | 3000984-15.patch | 6.36 KB | jrockowitz |
#13 | 3000984-14.patch | 5.41 KB | jrockowitz |
#10 | 3000984-10.patch | 4.77 KB | jrockowitz |
| |||
#10 | Manage display Webform Demo Site.png | 197.94 KB | jrockowitz |
Comments
Comment #2
John Cook CreditAttribution: John Cook at Creode commentedI'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:
Comment #3
John Cook CreditAttribution: John Cook at Creode commentedComment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedDid 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.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #6
John Cook CreditAttribution: John Cook at Creode commented@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:
If the patch in #2 is to be used, then an exception for this text needs to be created as well.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@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?
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe 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.
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.
Comment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch.
We can resolve how to handle a webform field displayed as a link within a paragraph in a new ticket.
Comment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedWow! I completely failed to apply this patch.
Comment #14
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 commentedBTW, I did figure out how to handle a webform field displayed as a link within a paragraph.