mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
DOCS Update HistoryViewerField to require javascript more consistently (#9773)
This commit is contained in:
parent
19af9cfc13
commit
bdb2deb3f5
@ -1264,18 +1264,33 @@ For more information, see [ReactJS, Redux and GraphQL](../../customising_the_adm
|
|||||||
|
|
||||||
### Adding the HistoryViewerField
|
### Adding the HistoryViewerField
|
||||||
|
|
||||||
You can add the [HistoryViewerField](api:SilverStripe\VersionedAdmin\Forms\HistoryViewerField) to your object's CMS
|
Firstly, ensure your JavaScript bundle is included throughout the CMS:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
---
|
||||||
|
Name: CustomAdmin
|
||||||
|
After:
|
||||||
|
- 'versionedadmincmsconfig'
|
||||||
|
- 'versionededitform'
|
||||||
|
- 'cmsscripts'
|
||||||
|
- 'elemental' # Only needed if silverstripe-elemental is installed
|
||||||
|
---
|
||||||
|
SilverStripe\Admin\LeftAndMain:
|
||||||
|
extra_requirements_javascript:
|
||||||
|
- app/client/dist/js/bundle.js
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can add the [HistoryViewerField](api:SilverStripe\VersionedAdmin\Forms\HistoryViewerField) to your object's CMS
|
||||||
fields in the same way as any other form field:
|
fields in the same way as any other form field:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use SilverStripe\VersionedAdmin\Forms\HistoryViewerField;
|
use SilverStripe\VersionedAdmin\Forms\HistoryViewerField;
|
||||||
use SilverStripe\View\Requirements;
|
|
||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
Requirements::javascript('app/client/dist/js/bundle.js');
|
|
||||||
$fields->addFieldToTab('Root.History', HistoryViewerField::create('MyObjectHistory'));
|
$fields->addFieldToTab('Root.History', HistoryViewerField::create('MyObjectHistory'));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
Loading…
Reference in New Issue
Block a user