This commit is contained in:
Guy Sartorelli 2024-10-14 01:51:04 +00:00 committed by GitHub
commit 410adfc541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,8 +31,9 @@ use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\Versioned;
use SilverStripe\Model\ArrayData; use SilverStripe\Model\ArrayData;
use SilverStripe\View\Requirements; use SilverStripe\View\Requirements;
use SilverStripe\View\SSViewer;
use SilverStripe\Model\ModelData; use SilverStripe\Model\ModelData;
use SilverStripe\View\TemplateEngine;
use SilverStripe\View\ViewLayerData;
use Swift_RfcComplianceException; use Swift_RfcComplianceException;
/** /**
@ -421,7 +422,8 @@ JS
// Include any parsed merge field references from the CMS editor - this is already escaped // Include any parsed merge field references from the CMS editor - this is already escaped
// This string substitution works for both HTML and plain text emails. // This string substitution works for both HTML and plain text emails.
// $recipient->getEmailBodyContent() will retrieve the relevant version of the email // $recipient->getEmailBodyContent() will retrieve the relevant version of the email
$emailData['Body'] = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields); $engine = Injector::inst()->create(TemplateEngine::class);
$emailData['Body'] = $engine->renderString($recipient->getEmailBodyContent(), ViewLayerData::create($mergeFields));
// only include visible fields if recipient visibility flag is set // only include visible fields if recipient visibility flag is set
if ((bool) $recipient->HideInvisibleFields) { if ((bool) $recipient->HideInvisibleFields) {
$emailData['Fields'] = $visibleSubmittedFields; $emailData['Fields'] = $visibleSubmittedFields;
@ -487,10 +489,10 @@ JS
if ($submittedFormField && trim($submittedFormField->Value ?? '')) { if ($submittedFormField && trim($submittedFormField->Value ?? '')) {
$email->setSubject($submittedFormField->Value); $email->setSubject($submittedFormField->Value);
} else { } else {
$email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields)); $email->setSubject($engine->renderString($recipient->EmailSubject, ViewLayerData::create($mergeFields)));
} }
} else { } else {
$email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields)); $email->setSubject($engine->renderString($recipient->EmailSubject, ViewLayerData::create($mergeFields)));
} }
$this->extend('updateEmail', $email, $recipient, $emailData); $this->extend('updateEmail', $email, $recipient, $emailData);