mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Recipient email content previews now when when userforms is used in a trait context
This commit is contained in:
parent
9b48b4f954
commit
c88d6b1566
@ -234,12 +234,17 @@ class EmailRecipient extends DataObject
|
||||
->getRequest()
|
||||
->setSession(Controller::curr()->getRequest()->getSession());
|
||||
|
||||
// If used in a regular page context, will have "/edit" on the end, if used in a trait context
|
||||
// it won't. Strip that off in case.
|
||||
$currentUrl = Controller::curr()->getRequest()->getURL();
|
||||
if (substr($currentUrl, -5) === '/edit') {
|
||||
$currentUrl = substr($currentUrl, 0, strlen($currentUrl) - 5);
|
||||
}
|
||||
$previewUrl = Controller::join_links($currentUrl, 'preview');
|
||||
|
||||
$preview = sprintf(
|
||||
'<p><a href="%s" target="_blank" class="btn btn-outline-secondary">%s</a></p><em>%s</em>',
|
||||
Controller::join_links(
|
||||
$pageEditController->getEditForm()->FormAction(),
|
||||
"field/EmailRecipients/item/{$this->ID}/preview"
|
||||
),
|
||||
$previewUrl,
|
||||
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.PREVIEW_EMAIL', 'Preview email'),
|
||||
_t(
|
||||
'SilverStripe\\UserForms\\Model\\UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION',
|
||||
|
Loading…
Reference in New Issue
Block a user