From 6e3050c6a2ad8309a56a144af4c0c7a7e28029c9 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 29 Nov 2023 14:10:44 +1300 Subject: [PATCH] ENH Use SearchableMultiDropdownField --- code/SiteConfig.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/code/SiteConfig.php b/code/SiteConfig.php index 87ea4bddc..a02db1ed9 100644 --- a/code/SiteConfig.php +++ b/code/SiteConfig.php @@ -22,6 +22,7 @@ use SilverStripe\Security\Security; use SilverStripe\View\TemplateGlobalProvider; use SilverStripe\CMS\Controllers\CMSMain; +use SilverStripe\Forms\SearchableMultiDropdownField; use SilverStripe\Security\InheritedPermissions; /** @@ -132,11 +133,13 @@ public function getCMSFields() 'data-placeholder', _t('SilverStripe\\CMS\\Model\\SiteTree.GroupPlaceholder', 'Click to select group') ), - $viewerMembersField = ListboxField::create( + $viewerMembersField = SearchableMultiDropdownField::create( "ViewerMembers", _t(self::class . '.VIEWERMEMBERS', "Viewer Users"), - $membersMap, - ), + Member::get() + ) + ->setIsLazyLoaded(true) + ->setUseSearchContext(true), $editorsOptionsField = OptionsetField::create( "CanEditType", _t(self::class . '.EDITHEADER', "Who can edit pages on this site?") @@ -150,11 +153,13 @@ public function getCMSFields() 'data-placeholder', _t('SilverStripe\\CMS\\Model\\SiteTree.GroupPlaceholder', 'Click to select group') ), - $editorMembersField = ListboxField::create( + $editorMembersField = SearchableMultiDropdownField::create( "EditorMembers", _t(self::class . '.EDITORMEMBERS', "Editor Users"), - $membersMap, - ), + Member::get(), + ) + ->setIsLazyLoaded(true) + ->setUseSearchContext(true), $topLevelCreatorsOptionsField = OptionsetField::create( "CanCreateTopLevelType", _t(self::class . '.TOPLEVELCREATE', "Who can create pages in the root of the site?") @@ -168,11 +173,13 @@ public function getCMSFields() 'data-placeholder', _t('SilverStripe\\CMS\\Model\\SiteTree.GroupPlaceholder', 'Click to select group') ), - $topLevelCreatorsMembersField = ListboxField::create( + $topLevelCreatorsMembersField = SearchableMultiDropdownField::create( "CreateTopLevelMembers", _t(self::class . '.TOPLEVELCREATORUSERS', "Top level creator users"), - $membersMap, + Member::get() ) + ->setIsLazyLoaded(true) + ->setUseSearchContext(true) ) ), HiddenField::create('ID')