Answers.Body: <p>Try appending ':label' (at least it works in Drupal 10.3 and  6.2.7)</p>
  <p>[submission:values:key_element_name:label]</p>
  <p>Note: for a field containing an entity</p>
  <p>[webform_submission:values:test] outputs 'test (1)'
  [webform_submission:values:concello:raw] outputs 'node:1'
  [webform_submission:values:concello:label] outputs 'test'</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-25T22:22:40.083Z
Answers.LastActivityDate: 2024-11-25T22:30:17.207Z
Answers.LastEditDate: 2024-11-25T22:30:17.207Z
Answers.UserDisplayName: Pin
Body: <p>I am converting Drupal webforms from Drupal 7 to Drupal 10 (Currently 10.2.1) and now using the excellent updated Webform module (6.2@beta).</p>
  <p>I thought I would post here first as this might be a CiviCRM-Webform issue rather than just a Drupal Webform issue.  Given the numbers of people doing what I am doing, someone must have run into this.</p>
  <p>In my old forms, I could chose to output to screen or email with or without a label by appending the <code>:nolabel</code>,<code>:withlabel</code> or <code>:label</code> atribute after the key name.</p>
  <p>As an example, in Drupal 7 using Webform 7.x-4.x, I could output the value of something without a label with:</p>
  <pre><code>[submission:values:key_element_name:nolabel]
  </code></pre>
  <p>or with a label:</p>
  <pre><code>[submission:values:key_element_name:withlabel]
  </code></pre>
  <p>The newer webform requires a slight change to the submission part of the token:</p>
  <pre><code>[webform_submission:values:key_element_mame]
  </code></pre>
  <p>This is easy to do with search and replace i.e. <code>[submission</code> with <code>[webform_submission</code> and the source text can just be lifted and reused.  I've done this and now have odd results and poor formatting.</p>
  <p>Looking at the documentation and doing a general search, it seems that <code>:nolabel</code> is no longer required, <code>[webform_submission:values:key_element_mame]</code> should output the label <strong>and</strong> the value, whilst to get just the value, one must add <code>:raw</code>.
  i.e.<code>[webform_submission:values:key_element_mame:raw]</code></p>
  <p>As a practical example, using: <code>[webform_submission:values:civicrm_1_contact_1_contact_first_name:raw]</code> or <code>[webform_submission:values:civicrm_1_contact_1_contact_first_name]</code> gives me exactly the same result, just the value.  I can print out only the first name of a contact without the label. I cannot seem to output label and value, or, just the label.</p>
  <p>The documentation lists the following as options:</p>
  <pre><code>element_key
  element_key:format
  element_key:raw
  element_key:format:items
  element_key:delta
  element_key:sub_element_key
  element_key:delta:sub_element_key
  element_key:sub_element_key:format
  element_key:delta:sub_element_key:format
  element_key:delta:format
  element_key:delta:format:html
  element_key:entity:*
  element_key:delta:entity:*
  element_key:delta:entity:field_name:*
  element_key:sub_element_key:entity:*
  element_key:sub_element_key:entity:field_name:*
  element_key:delta:sub_element_key:entity:*
  element_key:checked:option_value
  element_key:selected:option_value
  All items after the 'element_key' are optional.
  The 'delta' is the numeric index for specific value
  The 'sub_element_key' is a composite element's sub element key.
  The 'checked' or 'selected' looks to see if an 'option_value' is checked or selected for an options element (select, checkboxes, or radios)
  The 'option_value' is options value for an options element (select, checkboxes, or radios).
  The 'format' can be 'value', 'raw', or custom format specifically associated with the element
  The 'items' can be 'comma', 'semicolon', 'and', 'ol', 'ul', or custom delimiter
  The 'entity:*' applies to the referenced entity
  Add 'html' at the end of the token to return HTML markup instead of plain text.
  For example, to display the Contact webform's 'Subject' element's value you would use the [webform_submission:values:subject] token.
  </code></pre>
  <p>I've tried various combinations with no luck.  I could just type in the label myself, but this is solving the wrong problem.  It is really useful in the case where some data is null and the token as a whole will automaticaly not be displayed, so it formats nicely without missing lines.  Address data is a good example of this. Being able to change labels in one place and it reflects across all emails is another reason to use these tokens rather than hack it.</p>
  <p>I am struggling to get the result I need for a CiviCRM based form and would appreciate if anyone can let me know the correct syntax!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-02T11:12:20.630Z
Comments.Text: I can reproduce in a Drupal field only form and have raised an issue on Webform: https://www.drupal.org/project/webform/issues/3418861
Comments.UserDisplayName: ChumKui
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-03T17:05:58.583Z
Comments.Text: Evidently the behaviour has changed and will not be fixed in the current branch :-( I'll need to look at another workaround.
Comments.UserDisplayName: ChumKui
Tags: <webform-civicrm><tokens>
Title: Webform 6.2 Tokens not displaying label
ThreadText: # Webform 6.2 Tokens not displaying label
  
  (Asked by: username_0 on 2024-02-01)
  
  I am converting Drupal webforms from Drupal 7 to Drupal 10 (Currently 10.2.1) and now using the excellent updated Webform module (6.2@beta).
  
  I thought I would post here first as this might be a CiviCRM-Webform issue rather than just a Drupal Webform issue. Given the numbers of people doing what I am doing, someone must have run into this.
  
  In my old forms, I could chose to output to screen or email with or without a label by appending the `:nolabel`,`:withlabel` or `:label` atribute after the key name.
  
  As an example, in Drupal 7 using Webform 7.x-4.x, I could output the value of something without a label with:
  
  ```
  [submission:values:key_element_name:nolabel]
  
  ```
  
  or with a label:
  
  ```
  [submission:values:key_element_name:withlabel]
  
  ```
  
  The newer webform requires a slight change to the submission part of the token:
  
  ```
  [webform_submission:values:key_element_mame]
  
  ```
  
  This is easy to do with search and replace i.e. `[submission` with `[webform_submission` and the source text can just be lifted and reused. I've done this and now have odd results and poor formatting.
  
  Looking at the documentation and doing a general search, it seems that `:nolabel` is no longer required, `[webform_submission:values:key_element_mame]` should output the label **and** the value, whilst to get just the value, one must add `:raw`.
  i.e.`[webform_submission:values:key_element_mame:raw]`
  
  As a practical example, using: `[webform_submission:values:civicrm_1_contact_1_contact_first_name:raw]` or `[webform_submission:values:civicrm_1_contact_1_contact_first_name]` gives me exactly the same result, just the value. I can print out only the first name of a contact without the label. I cannot seem to output label and value, or, just the label.
  
  The documentation lists the following as options:
  
  ```
  element_key
  element_key:format
  element_key:raw
  element_key:format:items
  element_key:delta
  element_key:sub_element_key
  element_key:delta:sub_element_key
  element_key:sub_element_key:format
  element_key:delta:sub_element_key:format
  element_key:delta:format
  element_key:delta:format:html
  element_key:entity:*
  element_key:delta:entity:*
  element_key:delta:entity:field_name:*
  element_key:sub_element_key:entity:*
  element_key:sub_element_key:entity:field_name:*
  element_key:delta:sub_element_key:entity:*
  element_key:checked:option_value
  element_key:selected:option_value
  All items after the 'element_key' are optional.
  The 'delta' is the numeric index for specific value
  The 'sub_element_key' is a composite element's sub element key.
  The 'checked' or 'selected' looks to see if an 'option_value' is checked or selected for an options element (select, checkboxes, or radios)
  The 'option_value' is options value for an options element (select, checkboxes, or radios).
  The 'format' can be 'value', 'raw', or custom format specifically associated with the element
  The 'items' can be 'comma', 'semicolon', 'and', 'ol', 'ul', or custom delimiter
  The 'entity:*' applies to the referenced entity
  Add 'html' at the end of the token to return HTML markup instead of plain text.
  For example, to display the Contact webform's 'Subject' element's value you would use the [webform_submission:values:subject] token.
  
  ```
  
  I've tried various combinations with no luck. I could just type in the label myself, but this is solving the wrong problem. It is really useful in the case where some data is null and the token as a whole will automaticaly not be displayed, so it formats nicely without missing lines. Address data is a good example of this. Being able to change labels in one place and it reflects across all emails is another reason to use these tokens rather than hack it.
  
  I am struggling to get the result I need for a CiviCRM based form and would appreciate if anyone can let me know the correct syntax!
  
  **Tags:** webform-civicrm, tokens
  
  > **Comments:**
  > **username_0**: I can reproduce in a Drupal field only form and have raised an issue on Webform: https://www.drupal.org/project/webform/issues/3418861  
  > **username_0**: Evidently the behaviour has changed and will not be fixed in the current branch :-( I'll need to look at another workaround.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-11-25. Score: 1
  
  Try appending ':label' (at least it works in Drupal 10.3 and 6.2.7)
  
  [submission:values:key\_element\_name:label]
  
  Note: for a field containing an entity
  
  [webform\_submission:values:test] outputs 'test (1)'
  [webform\_submission:values:concello:raw] outputs 'node:1'
  [webform\_submission:values:concello:label] outputs 'test'
  
  
  ---
  
  