mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Upgrading guide for uploadfield
This commit is contained in:
parent
63e3fbdccb
commit
bf3383731d
@ -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'
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user