I am running 3.1.2 and trying to add a group of checkboxes to the CMS. I've added the form to manage the checkboxes to the CMS and that seems to work but I am unable t
I found an example on the internet from 2011 based on the 2.x framework and can't seem to get it working for 3.x. Feature.php and FeatureAdmin.php seem to work but I can't get the list of checkbox values to appear on a tab in the CMS labeled FeaturePage.php - the tab won't appear.
suggestions?
My code is below from mysite/code
FeaturePage.php
<?php
class FeaturePage extends Page {
// pages can have many features
static $many_many = array(
'Features' => 'Feature'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$features=Feature::get();
$map = $features->toDropdownMap('ID', 'Name', '(Select one)', true);
$fields->addFieldToTab('Root.Features', new CheckboxSetField($name = 'Features',$title = 'Select Features',$source = $map));
}
}
class FeaturePage_Controller extends Page_Controller {
}
FeatureAdmin.php
<?php
class FeatureAdmin extends ModelAdmin {
private static $managed_models = array(
'Feature'
);
private static $url_segment = 'features';
private static $menu_title = 'Features';
}
Feature.php
<?php
class Feature extends DataObject {
private static $db = array(
'Name' => 'Varchar(255)',
'Description' => 'HTMLText'
);
public function getCMSFields() {
$fields = new FieldList();
$fields->push(new TextField('Name', 'Name of the feature'));
$fields->push(new TextareaField('Description', 'Short description'));
return $fields;
}
}