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.

Customising the CMS

HasOneComplexTableField and Booleans


Reply

3 Posts   1409 Views

Avatar
_Vince

24 July 2009 at 1:36pm Community Member, 161 Posts

I have a HasOneComplexTableField on a page in the CMS and one of the columns displayed is of type 'Boolean'.

It's saved in the database as either 1 or 0 and it's DISPLAYED as either 1 or 0. Which is fair enough but potentially confusing for the end users.

Is there some way that I can "decode" the 1 and 0 into something like 'Y' and 'N' or whatever?

I only want that for the display.

Avatar
Willr

24 July 2009 at 2:37pm Forum Moderator, 5511 Posts

Perhaps create a new function (or try overloading your db field in your object). So say your boolean is "HasValue" => "Boolean" you can define something like getHasValueNice() { return ($this->HasValue) ? "Yes" : "No"; } and change your TableField to use HasValueNice rather then HasValue.

You could try overload it by creating a getHasValue() function (same as the dbfield) but not sure if you will run into other issues

Avatar
_Vince

24 July 2009 at 6:51pm (Last edited: 24 July 2009 7:26pm), Community Member, 161 Posts

Hey, that sounds interesting. I'll give it a go.

I can just see the end user asking what all those ones and zeros mean and I might as well preempt them. :)

ADDED:

Yup! Works perfectly. Sweet! Thanks!