I'm on D9, theming a webform email.
I'm currently overriding the twig file, instead of using the configuration of the body in the email hanlder, because there are various conditional logic I've to check - e.g. if interface language is en print element a otherwise element b.
To create the required markup, I need to get the info of the elements: for example, for select elements, I need the label and the text of the option selected, not the raw value.
However, I can't find them using the webform_submission, as it seems to contain only the raw data put by the user.
For now, I've find this way to get the info I need, but I'd like to know if there's a more direct\better way to get them:
webform-email-message-html--webform-id.html.twig
:
{% set submission_data =webform_submission.getData %}
{% set webform = handler.getWebform %}
{% set my_element_test = webform.getElementDecoded('element_id') %}
{% set option_label_test = my_element['#options']['options_id'] %}
{# todo print the markup for all elements #}