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:


or with a label:


The newer webform requires a slight change to the submission part of the token:


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:

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!

  • I can reproduce in a Drupal field only form and have raised an issue on Webform: drupal.org/project/webform/issues/3418861
    – ChumKui
    Feb 2 at 11:12
  • Evidently the behaviour has changed and will not be fixed in the current branch :-( I'll need to look at another workaround.
    – ChumKui
    Feb 3 at 17:05


Your Answer

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

Browse other questions tagged or ask your own question.