Silverstripe 4.10.2
I’m trying to add a few fields to the Folder edit screen in the cms. The site previously had this feature, but I think it has stopped working at some point after an update. I can see old values in the DB for DisplayName. The DisplayName field is not showing in the admin though.
How can I fix this?
More generally, how do I see what has gone wrong here? is there a debug method to seeing what extensions are applied for example?
There is a similar post for Image assets, which I have tried to apply lessons from , but it is still not working. Perhaps different for Folders
mysite.yml:
SilverStripe\AssetAdmin\Forms\FolderFormFactory:
extensions:
- 'DocumentFormFactoryExtension'
SilverStripe\Assets\Folder:
extensions:
- 'DocumentExtension'
DocumentExtension.php
<?php
use SilverStripe\ORM\DataExtension;
class DocumentExtension extends DataExtension
{
private static $db = [
'DisplayName' => 'Varchar',
'Description' => 'HTMLText',
'CustomOrder' => 'Int',
];
public function ShowTitle($title){
return str_replace('-', ' ', $title);
}
}
DocumentFormFactoryExtension.php
<?php
use SilverStripe\Core\Extension;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\TextField;
class DocumentFormFactoryExtension extends Extension
{
public function updateFormFields(FieldList $fields, $controller, $formName, $context)
{
$fields->insertAfter(
'Name',
TextField::create('DisplayName', 'Display name')
);
// I think these used to work before an update.
// $fields->addFieldToTab('Editor.Details', TextField::create('DisplayName', 'Display name'), 'Name');
// $fields->addFieldToTab('Editor.Details', HTMLEditorField::create('Description', 'Description')->setEditorConfig('basic'));
// $fields->addFieldToTab('Editor.Details', NumericField::create('CustomOrder', 'Custom order'));
}
}