mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: Convert newlines to <br /> tags in string fields (fixes #1942)
This commit is contained in:
parent
1c7b4a0cab
commit
4a158454d6
@ -96,6 +96,13 @@ abstract class StringField extends DBField {
|
|||||||
return parent::prepValueForDB($value);
|
return parent::prepValueForDB($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function forTemplate() {
|
||||||
|
return nl2br($this->XML());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limit this field's content by a number of characters.
|
* Limit this field's content by a number of characters.
|
||||||
|
@ -5,6 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class StringFieldTest extends SapphireTest {
|
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()
|
* @covers StringField->LowerCase()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user