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, Ed, biapar, Willr, Ingo, swaiba

Show icon in Admin for boolean

Go to End

2 Posts   554 Views


Community Member, 98 Posts

18 January 2013 at 4:20am

Edited: 18/01/2013 4:21am

How can i show "a Tick" or "a Cross" for a boolean value in model admin?

I have a boolean on a dataobject

When i show this in model admin
it intially showed up as 0 or 1

I've got to to say True or False instead

what i would like is an image instead.

However it actually prints out the html so i end up seeing

<span class="somestyle">True</span>

public static $db = array(
	'ShowIcon' => 'Boolean',

public static $summary_fields = array( 
       'ShowIconNice' => 'Active',
  	   'Title' => 'Title',
  	   'FooticonThumbnail' => 'Thumbnail'     

public function ShowIconNice(){
$trueorfalse ="nope";
//get value of boolean
$tfVALUE = $this->ShowIcon;
//set  result
$trueorfalse = $tfVALUE;

if($trueorfalse == 1){
$trueorfalse = '<span class="somestyle">True</span>';
} else {
$trueorfalse = "False";

return $trueorfalse;



Forum Moderator, 1848 Posts

18 January 2013 at 4:55am

Have you tried $casting the value to Text or Varchar?