Hello,
I extended the SiteTree (Silverstripe v2.3.2) with a DataObjectDecorator and want to access the newly added attribute in the decorator:
class SiteTreeCategory extends DataObjectDecorator {
...
function extraDBFields() {
return array(
'has_one' => array('Category' => 'Category')
);}
function updateCMSFields(FieldSet &$fields) {
$category = $this->owner->Category();
...
}
}
The decorator is registered in _config.php
DataObject::add_extension('SiteTree', 'SiteTreeCategory');
While accessing the admin section I receive the following error:
Uncaught Exception: Object->__call(): the method 'category' does not exist on 'Page'
Trace
* Object->__call(Category,Array)
* Page->Category()
Line 26 of SiteTreeCategory.php
* SiteTreeCategory->updateCMSFields(FieldSet,,,,,,)
Line 741 of Object.php
* Object->extend(updateCMSFields,FieldSet)
Line 1328 of SiteTree.php
* SiteTree->getCMSFields()
Line 13 of Page.php
* Page->getCMSFields(CMSMain)
Line 390 of CMSMain.php
I don´t have any idea about the reason of this error. Can anyone help me?
Best regards,
chrclaus