7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [SOLVED] Showing Yes instead of 1 in DOM with checkboxfield
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 771 Views |
-
[SOLVED] Showing Yes instead of 1 in DOM with checkboxfield

18 November 2009 at 11:02pm Last edited: 19 November 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
-
Re: [SOLVED] Showing Yes instead of 1 in DOM with checkboxfield

19 November 2009 at 12:57am Last edited: 19 November 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'),
-
Re: [SOLVED] Showing Yes instead of 1 in DOM with checkboxfield

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
-
Re: [SOLVED] Showing Yes instead of 1 in DOM with checkboxfield

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().
-
Re: [SOLVED] Showing Yes instead of 1 in DOM with checkboxfield

19 November 2009 at 3:23am
oh cool! I thought there was something like that but I could never remember what it was
| 771 Views | ||
|
Page:
1
|
Go to Top |


