Jump to:

22977 Posts in 11747 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Show icon in Admin for boolean

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

Page: 1
Go to End
Author Topic: 231 Views
  • merrick_sd
    Avatar
    Community Member
    89 Posts

    Show icon in Admin for boolean Link to this post

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

    details
    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;
    }

    [\code]

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Show icon in Admin for boolean Link to this post

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

    231 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.