FIX: Convert newlines to <br /> tags in string fields (fixes #1942)

This commit is contained in:
Loz Calver 2013-05-30 09:26:58 +01:00
parent 1c7b4a0cab
commit 4a158454d6
2 changed files with 17 additions and 0 deletions

View File

@ -97,6 +97,13 @@ abstract class StringField extends DBField {
}
}
/**
* @return string
*/
public function forTemplate() {
return nl2br($this->XML());
}
/**
* Limit this field's content by a number of characters.
* This makes use of strip_tags() to avoid malforming the

View File

@ -6,6 +6,16 @@
class StringFieldTest extends SapphireTest {
/**
* @covers StringField->forTemplate()
*/
public function testForTemplate() {
$this->assertEquals(
"this is<br />\na test!",
DBField::create_field('StringFieldTest_MyStringField', "this is\na test!")->forTemplate()
);
}
/**
* @covers StringField->LowerCase()
*/