fix: prevent CMS requirements from leaking into preview email

This commit is contained in:
Will Rossiter 2024-05-31 10:22:16 +12:00 committed by Will Rossiter
parent b429efb2ba
commit cccc3f7ec3
No known key found for this signature in database
GPG Key ID: 7FD2A809B22259EF

View File

@ -9,6 +9,7 @@ use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\UserForms\Model\EditableFormField\EditableFormHeading;
use SilverStripe\UserForms\Model\EditableFormField\EditableLiteralField;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
use SilverStripe\View\SSViewer;
/**
@ -34,14 +35,18 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest
Config::nest();
Config::modify()->set(SSViewer::class, 'theme_enabled', true);
Requirements::clear();
$content = $this->customise([
'Body' => $this->record->getEmailBodyContent(),
'HideFormData' => (bool) $this->record->HideFormData,
'Fields' => $this->getPreviewFieldData()
])->renderWith($this->record->EmailTemplate);
Requirements::restore();
Config::unnest();
return $content;
}