(Note: There seems to be a problem with Entity Reference elements in Webform 8.x-5.0-beta15, so this is being demonstrated on beta13. I opened a separate issue regarding the problem: https://www.drupal.org/node/2899524)
Here is what I'm trying to do:
Create a webform that will get values of fields from paragraphs in a node and display them as radio buttons.
Here is what I did:
1. Created a Paragraph Type
2. Created a content type and added a Paragraph field of the type I just created, with unlimited number of values
3. Created a node and added three paragraph items
4. Created a view of type Paragraph that correctly displays the Paragraph items and added a Entity Reference display for the view
5. Created a Webform and :
- Added an element of type: Entity radios
- Under ENTITY REFERENCE SETTINGS selected "Paragraph"
- Under "Reference method" selected "Views: Filter by entity reference view"
- Selected the Entity Reference view I created for the paragraphs (item 4 above)
6. Added a Webform field to the same content type
The node displays the form with three items with radio buttons, however the values of the Paragraph fields is not displayed. Instead it displays: the node title and field label from the content type. In my case it's displayed as follows (See also attached image):
O Node 1 > Article Paragraph Field
O Node 1 > Article Paragraph Field
O Node 1 > Article Paragraph Field
The same thing happens if I don't use a View in the webform, and instead use the default setting to show all paragraphs.
When testing with Taxonomy terms they are displays correctly using this same "Entity radios" element.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | paragraphs_as_entity-2899556-5.patch | 1.37 KB | jrockowitz |
| #4 | webform.webform.issue_2899556.yml | 2.9 KB | jrockowitz |
| paragraphs in webform.JPG | 30.62 KB | ericyellin |
Comments
Comment #2
ericyellin commentedComment #3
ericyellin commentedThis might be related:View output is not used for entityreference options
Comment #4
jrockowitz commentedAttached is a webform that replicates your exact issue. The problem is that the Paragraphs module does not support using paragraphs as an entity reference. @see http://cgit.drupalcode.org/paragraphs/tree/paragraphs.module?h=8.x-1.x#n99
I am going to disable Entity reference support for paragraphs in the webform module.
Comment #5
jrockowitz commented@ericyellin I know this was not the answer you were hoping for but this is definitely a Paragraphs related issue.
You might be able to use hook_webform_options_alter() or hook_webform_options_WEBFORM_OPTIONS_ID_alter() to create custom options that reference paragraphs.
Comment #7
jrockowitz commentedComment #9
drdam commentedJust link of the explaination from paragraph team : https://www.drupal.org/node/2722379
Comment #10
nathan tsai commentedI found a workaround for referencing paragraphs, although I don't know if it's defined behaviour though.
The only problem is that the output becomes "My View Name > My Display Name ([paragraph id])"
See #3249807: Paragraphs can be Referenced Multiple Times when using a View
Comment #11
nathan tsai commentedAble to solve the output as "My View Name > My Display Name ([paragraph id])" with a custom Webform Element extending the default entity_select element.
and
Also needed to remove the field and the field wrapper element in the view (since Webform only strips tags for the
webform_entity_selectelement.