0

If we have a link to a webform in a content type and we need to pass data or values to that webform from the fields available from the content type. How do we achieve this.

I'm using webform 8.x-5

I had hardly any success with 'Field Token Value' or setting default values from the available token of the webform build settings.

enter image description here

1 Answer 1

2

Add a webform reference field to the content type and put the default values in

Default submission data (YAML)

and you see this example provided by the field:

# This is an example of a comment.
element_key: 'some value'

# The below example uses a token to get the current node's title.
# Add ':clear' to the end token to return an empty value when the token is missing.
title: '[webform_submission:node:title:clear]'
# The below example uses a token to get a field value from the current node.
full_name: '[webform_submission:node:field_full_name:clear]
4
  • Thats for the reply let me try this and reply back Dec 9, 2018 at 10:56
  • Could you please axaplin it a bit more specific .. if i have a field 'field_email' how can i access this in the web form once i click 'Link to webform' .. Thanks in advance Dec 9, 2018 at 11:07
  • 1
    The link will contain ?_source_entity_type=node&source_entity_id=NID which will pass the node to the webform and allow you to use a [webform_submission:node:field_email:clear] token as the default data or even the element's default value.
    – jrockowitz
    Dec 16, 2018 at 17:05
  • I agree with the idea and the link definitely passes the the source_entity and ID. But a very few tokens are available to use as default values, like current-page:url. None of the [webform_submission:node] returns any value. I believe [webform_submission:node] and related tokens are supposed to return the datas from 'The node that the webform was submitted from'. I'm using this webform in commerce product type. Will that may be a possibility the tokens are not available as commerce products are not exactly nodes. Dec 17, 2018 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.