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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Boolean->Nice in ModelAdmin


Go to End


2 Posts   2120 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

15 September 2010 at 12:32am

Hi,

In the ss book (when created a TableListField for displaying data) there is a line to cast Boolean data into 'Boolean->Nice' so that instead of Value (field name) and 0 or 1 (data) instead appears Value? and Yes or No.

Is there away to apply this to ModelAdmin please?

Barry

Avatar
swaiba

Forum Moderator, 1899 Posts

22 September 2010 at 9:27pm

found the answer...

static $casting = array(
   "MyTextBoolean" => "Text"
);

public static $summary_fields = array (
	...
	'MyTextBoolean'=>'IsTrue?',
);

public function MyTextBoolean()
{
	$str = 'No';
	if ($this->BooleanField== true)
		$str = 'Yes';

	return $str;
}