I am trying to add image to blogs in silvertstripe 3.1 with the help of the following code:
<?php
class BlogEntryDecorator extends DataExtension {
static $has_one = array(
'BlogImage' => 'Image'
);
public function updateCMSFields(FieldList $fields) {
parent::updateCMSFields($fields);
$fields->addFieldToTab("Root.Main", $BlogImage = new UploadField('BlogImage'), 'Content');
$BlogImage->getValidator()->setAllowedExtensions(File::$app_categories['image']);
}
}
?>
<?php
#-------------------------------------------------------------
# Edit file: mysite/code/_config.php
#-------------------------------------------------------------
Object::add_extension('BlogEntry', 'BlogEntryDecorator');
?>
When I try to build database again, I get an error.
On further research I realized Object::add_extension is deprecated and I have to use something like the following
BlogEntry:
extensions:
- BlogEntryDecorator
I am not sure about the above code & which file should I put the same in.
Kindly suggest