Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

$summary_fields with HTML?


3 Posts   292 Views


18 December 2013 at 8:52pm Community Member, 94 Posts

Hey guys,

Is it possible to display HTML content in $summary_fields?

static $summary_fields = array(
'Title' => 'Title,
'myHTMLString' => 'HTML String'

public function myHTMLString(){
return "Lorum ipsum <table><tr><td>Blabla</td></tr></table>";

If I do it that way, I get the HTML elements back as string.


19 December 2013 at 1:07am Community Member, 94 Posts

Found a solution. Not very nice, but it works for me:

Add "htmlspecialchars_decode" in frameworks/forms/gridfield/GridField.php line 353:

$rowContent .= FormField::create_tag('td', $colAttributes, htmlspecialchars_decode($colContent));


23 December 2013 at 11:27am Forum Moderator, 5511 Posts

You can use setFieldFormatting (e.g to override formatting for a column value. Perhaps also try adding your custom summary field to the $casting array, I wonder if GridField picks up the objects casting

private static $casting = array(
'MyField' => 'HTMLText'

private static $summary_fields = array(