Customize f*cks up HTML

Silverstripe Version: 4.3.3

Question: I cant use customize anymore with HTML Code

the HTML-Code gets HTMLed so < becomes &lgt; ect. So I can not Costomize Content.

$content.= "<p>Some HTML code here</p>";
return $this->customise(array(
	"Success" => true,
	"Headline" => "Vielen Dank für die Anmeldung!",
	"Content" => "<div class='center'>".$content."</div>",
	"YoungsterAnmeldeForm" => ""
));

searching for this for days. No I’ve found the Answer by accident. HTMLValue::create works fine.

```
$content.= "<p>Some HTML code here</p>";
return $this->customise(array(
	"Success" => true,
	"Headline" => "Vielen Dank für die Anmeldung!",
	"Content" => HTMLValue::create("<div class='center'>".$content."</div>"),
	"YoungsterAnmeldeForm" => ""
));
```
1 Like

customise() is not the culprit: SilverStripe (or anyone else) cannot know if you want to escape $Content or not, so it stays on the safe side and escape by default. You can change this behavior by using the casting feature or, better yet, to explicitely select what you want to do at template level:

$Content (depend on casting, XML by default)
$Content.RAW (not escaped)
$Content.XML (escaped for HTML)
$Content.ATT (escaped for attribute values)

There are a few other escaping options: check the source code for further details.

1 Like

thanks for the Hint. So .RAW it is. I tried different things like NoHTML, but than i had no content at all.