BUG Suppress HtmlEditorField casting

Fixes #6396
This commit is contained in:
Damian Mooyman 2016-12-16 16:51:15 +13:00
parent 1ea4f29dbe
commit c007e85d1b
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
4 changed files with 29 additions and 9 deletions

View File

@ -26,14 +26,6 @@ class HtmlEditorField extends TextareaField {
*/
private static $sanitise_server_side = false;
/**
* @config
* @var array
*/
private static $casting = array(
'Value' => 'HTMLText',
);
protected $rows = 30;
/**

View File

@ -20,7 +20,7 @@
class TextareaField extends FormField {
private static $casting = array(
'Value' => 'HTMLText',
'Value' => 'HTMLText(array("shortcodes" => 0))',
);
/**

View File

@ -15,6 +15,20 @@ class HtmlEditorFieldTest extends FunctionalTest {
protected $extraDataObjects = array('HtmlEditorFieldTest_Object');
public function testCasting() {
// Test special characters
$inputText = "These are some unicodes: ä, ö, & ü";
$field = new HTMLEditorField("Test", "Test");
$field->setValue($inputText);
$this->assertContains('These are some unicodes: ä, ö, & ü', $field->Field());
// Test shortcodes
$inputText = "Shortcode: [file_link id=4]";
$field = new HTMLEditorField("Test", "Test");
$field->setValue($inputText);
$this->assertContains('Shortcode: [file_link id=4]', $field->Field());
}
public function testBasicSaving() {
$obj = new HtmlEditorFieldTest_Object();
$editor = new HtmlEditorField('Content');

View File

@ -2,6 +2,20 @@
class TextareaFieldTest extends SapphireTest {
public function testCasting() {
// Test special characters
$inputText = "These are some unicodes: ä, ö, & ü";
$field = new TextareaField("Test", "Test");
$field->setValue($inputText);
$this->assertContains('These are some unicodes: ä, ö, & ü', $field->Field());
// Test shortcodes
$inputText = "Shortcode: [file_link id=4]";
$field = new TextareaField("Test", "Test");
$field->setValue($inputText);
$this->assertContains('Shortcode: [file_link id=4]', $field->Field());
}
/**
* Quick smoke test to ensure that text with unicodes is being displayed properly in readonly fields.
*/