I'm trying to create a CheckboxSetField but I keep on getting the following error message when the CMS Popup appears:
"Fatal error: Call to a member function Name() on a non-object in" ... "\sapphire\forms\FieldSet.php on line 395"
When I remove the checkbox field from the popup it works fine - so I'm sure its isolated to just the CheckboxSetField. I have looked over the Silverstripe documentation and I can't see what I am doing wrong. Below is the code that I am using - Any ideas? (Just in case - I'm using WAMP to develop this site and have updated to the latest stable version - SilverStripe-v2.3.2)
ProductDetail.php
<?php
class ProductDetail extends DataObject {
...
static $many_many = array(
'FilterColor' => 'FilterColor',
...
);
function getCMSFields_forPopup() {
$FilterColorObj = DataObject::get('FilterColor');
$FilterColorMap = $FilterColorObj ? $FilterColorObj->toDropdownMap('ID','Title') : array();
$FilterColorList = new CheckboxSetField(
'FilterColor',
'FilterColor',
$FilterColorMap
);
$fields->push( $filterColorList );
...
return $fields;
}
}
?>
FilterColor.php
<?php
class FilterColor extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Hex' => 'Varchar'
);
public static $belongs_many_many = array(
'ProductDetail' => 'ProductDetail',
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Title', 'Colour' ) );
$fields->push( new TextField( 'Hex', 'Hex', '', 6 ) );
return $fields;
}
}
?>