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   935 Views

Avatar
LesC

Community Member, 70 Posts

18 November 2009 at 11:02pm

Edited: 19/11/2009 1:04am

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
Carbon Crayon

Community Member, 598 Posts

19 November 2009 at 12:57am

Edited: 19/11/2009 12:57am

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

Community Member, 70 Posts

19 November 2009 at 1:03am

Hi Aram,

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

L

Avatar
UncleCheese

Forum Moderator, 4096 Posts

19 November 2009 at 3:16am

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
Carbon Crayon

Community Member, 598 Posts

19 November 2009 at 3:23am

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