I am trying to add a tab to AssetAdmin (as part of an attempt to upgrade Hamish Campbell's secure files module) and am having difficulty adding the Security tab in AssetAdmin.
I have looked over the code in AssetAdmin and found the code that appears to be responsible for the tabs in AssetsAdmin:
cms/code/controllers/AssetAdmin.php
if(!$fields->hasTabset()) {
$tabs = new TabSet('Root',
$tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')),
$tabTree = new Tab('TreeView', _t('AssetAdmin.TreeView', 'Tree View'))
);
....
}
In the File decorator class in secure files I have changed the updateCMSFields method to be compatible with SS3:
function updateCMSFields(FieldList $fields) {
// Only modify folder objects with parent nodes
if(!($this->owner instanceof Folder) || !$this->owner->ID)
return;
// Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
if(!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS')))
return;
$secureFilesTab = $fields->findOrMakeTab('Root.'._t('SecureFiles.SECUREFILETABNAME', 'Security'));
...
Unfortunately, this is giving me the following error:
Error at framework/forms/FieldList.php line 288: FieldList::addFieldToTab() Tried to add a tab to object 'FieldList' - 'Root' didn't exist
I have found the code in FieldList.php that is producing this error message:
if(is_a($parentPointer, 'TabSet')) {
// use $title on the innermost tab only
if ($k == $last_idx) {
$currentPointer = isset($title) ? new Tab($part, $title) : new Tab($part);
}
else {
$currentPointer = new TabSet($part);
}
$parentPointer->push($currentPointer);
}
else {
$withName = ($parentPointer->hasMethod('Name')) ? " named '{$parentPointer->getName()}'" : null;
user_error("FieldList::addFieldToTab() Tried to add a tab to object '{$parentPointer->class}'{$withName} - '$part' didn't exist.", E_USER_ERROR);
}
I do not understand why 'Root' is not a TabSet, cinse it appears to be set as such in AssetAdmin.
Can anybody please help out on this one?