mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Ensure HTML email preview content is parsed as HTML including shortcodes
This commit is contained in:
parent
802c750a77
commit
bf20e19285
@ -417,7 +417,10 @@ class UserDefinedForm_EmailRecipient extends DataObject
|
||||
*/
|
||||
public function getEmailBodyContent()
|
||||
{
|
||||
return $this->SendPlain ? $this->EmailBody : $this->EmailBodyHtml;
|
||||
if ($this->SendPlain) {
|
||||
return DBField::create_field('HTMLText', $this->EmailBody)->NoHTML();
|
||||
}
|
||||
return DBField::create_field('HTMLText', $this->EmailBodyHtml)->RAW();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class UserDefinedForm_EmailRecipientTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'UserDefinedForm_EmailRecipientTest.yml';
|
||||
|
||||
public function testShortcodesAreRenderedInEmailPreviewContent()
|
||||
{
|
||||
$page = $this->objFromFixture('SiteTree', 'about_us');
|
||||
|
||||
$recipient = UserDefinedForm_EmailRecipient::create();
|
||||
$recipient->SendPlain = false;
|
||||
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
||||
|
||||
$result = $recipient->getEmailBodyContent();
|
||||
$this->assertContains('/about-us/', $result);
|
||||
|
||||
$recipient->SendPlain = true;
|
||||
$recipient->EmailBody = 'Some email content. About us: [sitetree_link,id=' . $page->ID . '].';
|
||||
|
||||
$result = $recipient->getEmailBodyContent();
|
||||
$this->assertContains('/about-us/', $result);
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
SiteTree:
|
||||
about_us:
|
||||
Title: About Us
|
||||
URLSegment: about-us
|
Loading…
Reference in New Issue
Block a user