🇹🇳Tunisia A-Marwen
priting praemters and webformfields in email template
in case you want to print the parameters or the webfom fields inside the email.html.twig add this preprocess to your .theme file :
/**
* Implements hook_preprocess_HOOK
*/
function d10_preprocess_email(&$variables) {
/** @var Drupal\symfony_mailer\Email $email*/
$email = $variables['email'];
// {% set params = _context.email.params.legacy_message.params %}
/** @var Drupal\webform\Entity\WebformSubmission $webform_submission */
$params = $email->getParam('legacy_message')['params'];
$webFormSubmission = $params['webform_submission'];
// collecting the webform fields into an array.
$variables['params'] = $webFormSubmission->getData();
$variables['form'] = $webFormSubmission->getData();
}
then in the email.html.twig just use form.{webformfieldName} EX :
<ul>
<li>{{ form.entreprise_email }}</li>
<li>{{ form.message }}</li>
<li>{{ form.domain }}</li>
</ul>
🇹🇳Tunisia A-Marwen
in case you want to print the parameters or the webfom fields inside the email.html.twig add this preprocess to your .theme file :
/**
* Implements hook_preprocess_HOOK
*/
function d10_preprocess_email(&$variables) {
/** @var Drupal\symfony_mailer\Email $email*/
$email = $variables['email'];
// {% set params = _context.email.params.legacy_message.params %}
/** @var Drupal\webform\Entity\WebformSubmission $webform_submission */
$params = $email->getParam('legacy_message')['params'];
$webFormSubmission = $params['webform_submission'];
// collecting the webform fields into an array.
$variables['params'] = $webFormSubmission->getData();
$variables['form'] = $webFormSubmission->getData();
}
then in the email.html.twig just use form.{webformfieldName} EX :
<ul>
<li>{{ form.entreprise_email }}</li>
<li>{{ form.message }}</li>
<li>{{ form.domain }}</li>
</ul>
🇹🇳Tunisia A-Marwen
in case someone wants to pronts the parameters or the webfom fields from inside the email.html.twig add this preprocess to yout .theme file :
/**
* Implements hook_preprocess_HOOK
*/
function d10_preprocess_email(&$variables) {
/** @var Drupal\symfony_mailer\Email $email*/
$email = $variables['email'];
// {% set params = _context.email.params.legacy_message.params %}
/** @var Drupal\webform\Entity\WebformSubmission $webform_submission */
$params = $email->getParam('legacy_message')['params'];
$webFormSubmission = $params['webform_submission'];
// collecting the webform fields into an array.
$variables['params'] = $webFormSubmission->getData();
$variables['form'] = $webFormSubmission->getData();
}
then in the email.html.twig just use form.{webformfieldName} EX :
<ul>
<li>{{ form.entreprise_email }}</li>
<li>{{ form.message }}</li>
<li>{{ form.domain }}</li>
</ul>