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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

[SOLVED] Showing Yes instead of 1 in DOM with checkboxfield


Reply

5 Posts   901 Views

Avatar
LesC

18 November 2009 at 11:02pm (Last edited: 19 November 2009 1:04am), Community Member, 70 Posts

Hi,

I'd like to show the status of a checkbox field in the DOM list, but rather than it showing '1' I'd like to translate it to 'Yes', so it's easier for my clients to scan.

I'm using this:

$f->addFieldToTab("Root.Content.DirectoryEntries", new DataObjectManager(
$this,
'DirectoryEntries',
'DirectoryEntry',
array('DirectoryTitle' => 'Title','DirectoryPractitioner' => 'Practitioner', 'DirectoryCategoryTitle' => 'Category', 'Premium' => 'Premium'),
'getCMSFields_forPopup'
));

I'm guessing this is something simple?

L

Avatar
Aram

19 November 2009 at 12:57am (Last edited: 19 November 2009 12:57am), Community Member, 598 Posts

Hi Les

This is simple, just add this function to your dataobject (this example would be for the checkbox 'Premium':

   public function GetPremiumValue(){
      return ($this->Premium) ? 'Yes' : 'no';
   }

Then change the array in the DOM definition to be:

array('DirectoryTitle' => 'Title','DirectoryPractitioner' => 'Practitioner', 'DirectoryCategoryTitle' => 'Category', 'GetPremiumValue' => 'Premium'),

Avatar
LesC

19 November 2009 at 1:03am Community Member, 70 Posts

Hi Aram,

That's exactly what I needed - thanks - I'm starting to understand how this all fits together now!!

L

Avatar
UncleCheese

19 November 2009 at 3:16am 4085 Posts

Thanks for stepping in, Aram!

BTW, you don't need 'GetPremiumValue' in your array. You can just do PremiumValue, and name the function getPremiumValue().

Avatar
Aram

19 November 2009 at 3:23am Community Member, 598 Posts

oh cool! I thought there was something like that but I could never remember what it was :)