I'm using Drupal 8.7.8 and Webform 5.4.0. I have multiple section nodes that are displayed on course nodes. These are 2 different content types.
I'm adding webforms to sections, via the twig file conditionally (not all sections) with {{ drupal_entity('webform', 'my_form_id') }}
and I need to pass the value of field_code
of the section into a hidden field on the webform.
Once the form is rendered on the course page, the field_code
value passed belongs to the course node rather than the section. How can I access the field_code
value on the section?
I tried adding a hidden field with this token as the default [webform_submission:node:field_code:value]
, which works when I test the form on the section, but when I test the form on the course (where the user will access it) I'm getting the field_code
value of the course.
What's the best way to handle this? Is there a way to set the source entity to the content type that the form is on? Please let me know if I need to add more info.
Thanks!
drupal_entity
because the fallback function of the drupal_entity extension accept 5 argument$entity_type
$id
$view_mode
$langcode
and$check_access
, so i suggest to develop new extension like drupal_entity with another argument [field_machine_name => value] to set value of field