diff --git a/code/model/recipients/UserDefinedForm_EmailRecipient.php b/code/model/recipients/UserDefinedForm_EmailRecipient.php index 1636492..5348b7e 100644 --- a/code/model/recipients/UserDefinedForm_EmailRecipient.php +++ b/code/model/recipients/UserDefinedForm_EmailRecipient.php @@ -266,7 +266,7 @@ class UserDefinedForm_EmailRecipient extends DataObject '
' . $preview . '
' ) )); - + $fields->fieldByName('Root.EmailContent')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILCONTENTTAB', 'Email Content')); // Custom rules for sending this field @@ -291,7 +291,7 @@ class UserDefinedForm_EmailRecipient extends DataObject ), $grid )); - + $fields->fieldByName('Root.CustomRules')->setTitle(_t('UserDefinedForm_EmailRecipient.CUSTOMRULESTAB', 'Custom Rules')); $this->extend('updateCMSFields', $fields); @@ -420,7 +420,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(); } /** diff --git a/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php new file mode 100644 index 0000000..237560a --- /dev/null +++ b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.php @@ -0,0 +1,24 @@ +objFromFixture('SiteTree', 'about_us'); + + $recipient = UserDefinedForm_EmailRecipient::create(); + $recipient->SendPlain = false; + $recipient->EmailBodyHtml = '

Some email content. About us: [sitetree_link,id=' . $page->ID . '].

'; + + $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); + } +} diff --git a/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml new file mode 100644 index 0000000..7ff28c7 --- /dev/null +++ b/tests/model/recipients/UserDefinedForm_EmailRecipientTest.yml @@ -0,0 +1,4 @@ +SiteTree: + about_us: + Title: About Us + URLSegment: about-us