From bdb2deb3f55970fcd198a99128cffc4e21ef4545 Mon Sep 17 00:00:00 2001 From: Scott Hutchinson Date: Tue, 17 Nov 2020 10:56:50 +1300 Subject: [PATCH] DOCS Update HistoryViewerField to require javascript more consistently (#9773) --- .../00_Model/10_Versioning.md | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md index 571e349f7..16188bdee 100644 --- a/docs/en/02_Developer_Guides/00_Model/10_Versioning.md +++ b/docs/en/02_Developer_Guides/00_Model/10_Versioning.md @@ -1264,18 +1264,33 @@ For more information, see [ReactJS, Redux and GraphQL](../../customising_the_adm ### 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: ```php use SilverStripe\VersionedAdmin\Forms\HistoryViewerField; -use SilverStripe\View\Requirements; public function getCMSFields() { $fields = parent::getCMSFields(); - Requirements::javascript('app/client/dist/js/bundle.js'); $fields->addFieldToTab('Root.History', HistoryViewerField::create('MyObjectHistory')); return $fields;