Upgrading guide for uploadfield

This commit is contained in:
Damian Mooyman 2017-03-09 11:11:41 +13:00
parent 63e3fbdccb
commit bf3383731d
2 changed files with 42 additions and 1 deletions

View File

@ -10,7 +10,7 @@ to track down a template or two. The template engine can help you along by displ
source code comments indicating which template is responsible for rendering each
block of html on your page.
::::yaml
:::yaml
---
Only:
environment: 'dev'

View File

@ -267,6 +267,47 @@ instead, or if used in an actual XML file use `.CDATA` (see [template casting](/
Where your code once used SQLQuery you should now use SQLSelect in all cases, as this has been removed (check the [3.2.0](3.2.0) upgrading notes).
#### Upgrade code that uses UploadField
This field has been superceded by a new class provided by the
[asset-admin](https://github.com/silverstripe/silverstripe-asset-admin) module, which provides a more
streamlined simpler mechanism for uploading File dataobjects.
A helper service `FileHandleField` is provided to assist with dependency injection. Where the asset-admin
module is not installed this service will fall back to the `FileField` class instead.
Usages of UploadField will need to be upgraded as below:
3.x code
:::php
class MyClass extends DataObject {
public function getCMSFields() {
return new FieldList(
new UploadField('Files')
);
}
}
4.x code
:::php
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\FileHandleField;
class MyClass extends DataObject {
public function getCMSFields() {
return FieldList::create(
Injector::inst()->create(FileHandleField::class, 'Files')
);
}
}
#### Upgrade code that uses i18n
In many cases, localisation strings which worked in 3.x will continue to work in 4.0, however certain patterns