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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

checkbox question (probably very easy one!)


3 Posts   1101 Views


13 September 2009 at 9:35am Community Member, 80 Posts

I have an image I am using on my home page that is controlled form the Image tab on my CMS for that page. I added treedropdown field and then a checkbox to note if the user wants the selected page to be a link or not.

I cant get the checkbox to control the IF statement. Do i need to do something else in the IF statement, like note a value or something? right now the IF staement makes the DonatePhotoLink div appear all the time no matter the checkbox state. Thanks in advance!

<div id="DonateImageHome">
            <div id="DonatePhotoHome">$Photo</div>
            <% if ActivateLink %><div id="DonatePhotoLink">&nbsp;</div><% end_if %>


class Page extends SiteTree {
   static $db = array(
    static $has_one = array(
'Photo' => 'Image',
    'MainImageLink' => 'SiteTree',
    'ActivateLink' => 'Boolean'

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Images", new ImageField("Photo"));
   $fields->addFieldToTab('Root.Content.Images', new TreeDropdownField('MainImageLinkID', 'Link image to', 'SiteTree'));
   $fields->addFieldToTab('Root.Content.Images', new CheckboxField ('ActivateLink'));
return $fields;



13 September 2009 at 9:49am Forum Moderator, 5511 Posts

The 'ActivateLink' => 'Boolean' should be in the $db array, not the has_one array. Move that and run dev/build again, select the checkbox again in the cms, save and that should fix it.


13 September 2009 at 10:08am Community Member, 80 Posts

That did it! Cheers. and for me...Doh!