5099 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1008 Views |
-
Checkbox in admin cannot be "unchecked"

11 February 2009 at 1:52pm
Hi
I have added a checkbox to the admin area which allows the adminstrator to indicate whether they want a section of a page to be displayed or not.
class Page extends SiteTree {
static $db = array(
);
...,
'ContactUsValue' => 'Boolean',
...
);
function getCMSFields() {
$fields = parent::getCMSFields();
..
$fields->addFieldToTab("Root.Content.Main", new CheckboxField ('ContactUsValue', 'Contact Us link?'), Content);
...
return $fields;
}
}Clicking the checkbox reveals the section. The problem occurs when they decide they want to remove it again. When they return to the page in question the checkbox doesn't display a tick and checking, then unchecking and saving does not change the flag. Any ideas?
Thanks
MM
-
Re: Checkbox in admin cannot be "unchecked"

27 February 2009 at 1:24pm
Oops - user error. This code works perfectly. Had put the boolen in static $has_one = array(} by mistake.
| 1008 Views | ||
|
Page:
1
|
Go to Top |
