I've created a simple extension to SiteConfig
to add a logo uploadfield to the settings section. However, the server returns an error upon uploading a file.
SiteConfig.php
namespace mymodule\siteconfig;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
use SilverStripe\AssetAdmin\Forms\UploadField;
class SiteConfig extends DataExtension {
private static $has_one = array(
'Logo' => 'SilverStripe\\Assets\\File'
);
public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main', $logo = UploadField::create('Logo', 'Logo upload'));
}
}
Server's error log does not show anything relevant to this error. Whats going on here?
UPDATE
I just tried to upload a file to the Files section in the CMS, got the exact same error.
private static $has_one = [
'LogoImage' => Image::class,
];
public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main', UploadField::create('LogoImage', 'Logo'));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.