Merge pull request #2034 from kinglozzer/1942-stringfield-newlines

FIX: Convert newlines to <br /> tags in string fields (fixes #1942)
This commit is contained in:
Simon Welsh 2013-05-30 01:45:17 -07:00
commit 87694b7f72
2 changed files with 17 additions and 0 deletions

View File

@ -96,6 +96,13 @@ abstract class StringField extends DBField {
return parent::prepValueForDB($value);
}
}
/**
* @return string
*/
public function forTemplate() {
return nl2br($this->XML());
}
/**
* Limit this field's content by a number of characters.

View File

@ -5,6 +5,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()