public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            if ($this->exists()) {
                // Add a GridField for domains to a new tab if the subsite has already been created
                $fields->addFieldsToTab('Root.Domains', [
                    GridField::create(
                        'Domains',
                        '',
                        $this->Domains(),
                        GridFieldConfig_RecordEditor::create(10)
                    )
                ]);
            }

            // Remove the default scaffolded blacklist field, we replace it with a checkbox set field
            // in a wrapper further down. The RedirectURL field is currently not in use.
            $fields->removeByName(['PageTypeBlacklist', 'RedirectURL']);

            $fields->addFieldToTab('Root.Main', DropdownField::create(
                'Language',
                $this->fieldLabel('Language'),
                Injector::inst()->get(IntlLocales::class)->getLocales()
            ), 'DefaultSite');

            $fields->addFieldsToTab('Root.Main', [
                ToggleCompositeField::create(
                    'PageTypeBlacklistToggle',
                    _t(__CLASS__ . '.PageTypeBlacklistField', 'Disallow page types?'),
                    [
                        CheckboxSetField::create('PageTypeBlacklist', '', $this->getPageTypeMap())
                    ]
                )->setHeadingLevel(4),
                HiddenField::create('ID', '', $this->ID),
                HiddenField::create('IsSubsite', '', 1)
            ]);

            // If there are any themes available, add the dropdown
            $themes = $this->allowedThemes();
            if (!empty($themes)) {
                $fields->addFieldToTab(
                    'Root.Main',
                    DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)
                        ->setEmptyString(_t(__CLASS__ . '.ThemeFieldEmptyString', '-')),
                    'PageTypeBlacklistToggle'
                );
            }

            // Targetted by the XHR PJAX JavaScript to reload the subsite list in the CMS
            $fields->fieldByName('Root.Main')->addExtraClass('subsite-model');

            // We don't need the Groups many many tab
            $fields->removeByName('Groups');

            // Rename the main tab to configuration
            $fields->fieldByName('Root.Main')->setTitle(_t(__CLASS__ . '.ConfigurationTab', 'Configuration'));
        });

        return parent::getCMSFields();
    }
public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            if ($this->exists()) {
                // Add a GridField for domains to a new tab if the subsite has already been created
                $fields->addFieldsToTab('Root.Domains', [
                    GridField::create(
                        'Domains',
                        '',
                        $this->Domains(),
                        GridFieldConfig_RecordEditor::create(10)
                    )
                ]);
            }

            // Remove the default scaffolded blacklist field, we replace it with a checkbox set field
            // in a wrapper further down. The RedirectURL field is currently not in use.
            $fields->removeByName(['PageTypeBlacklist', 'RedirectURL']);

            $fields->addFieldToTab('Root.Main', DropdownField::create(
                'Language',
                $this->fieldLabel('Language'),
                Injector::inst()->get(IntlLocales::class)->getLocales()
            ), 'DefaultSite');

            $fields->addFieldsToTab('Root.Main', [
                ToggleCompositeField::create(
                    'PageTypeBlacklistToggle',
                    _t(__CLASS__ . '.PageTypeBlacklistField', 'Disallow page types?'),
                    [
                        CheckboxSetField::create('PageTypeBlacklist', '', $this->getPageTypeMap())
                    ]
                )->setHeadingLevel(4),
                HiddenField::create('ID', '', $this->ID),
                HiddenField::create('IsSubsite', '', 1)
            ]);

            // If there are any themes available, add the dropdown
            $themes = $this->allowedThemes();
            if (!empty($themes)) {
                $fields->addFieldToTab(
                    'Root.Main',
                    DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)
                        ->setEmptyString(_t(__CLASS__ . '.ThemeFieldEmptyString', '-')),
                    'PageTypeBlacklistToggle'
                );
            }

            // Targetted by the XHR PJAX JavaScript to reload the subsite list in the CMS
            $fields->fieldByName('Root.Main')->addExtraClass('subsite-model');

            // We don't need the Groups many many tab
            $fields->removeByName('Groups');

            // Rename the main tab to configuration
            $fields->fieldByName('Root.Main')->setTitle(_t(__CLASS__ . '.ConfigurationTab', 'Configuration'));
        });

        return parent::getCMSFields();
    }
public function getCMSFields ( ) { $ this -> beforeUpdateCMSFields ( function ( FieldList $ fields ) { if ( $ this -> exists ( ) ) { // Add a GridField for domains to a new tab if the subsite has already been created $ fields -> addFieldsToTab ( 'Root.Domains' , [ GridField :: create ( 'Domains' , '' , $ this -> Domains ( ) , GridFieldConfig_RecordEditor :: create ( 10 ) ) ] ) ; } // Remove the default scaffolded blacklist field, we replace it with a checkbox set field // in a wrapper further down. The RedirectURL field is currently not in use. $ fields -> removeByName ( [ 'PageTypeBlacklist' , 'RedirectURL' ] ) ; $ fields -> addFieldToTab ( 'Root.Main' , DropdownField :: create ( 'Language' , $ this -> fieldLabel ( 'Language' ) , Injector :: inst ( ) -> get ( IntlLocales :: class ) -> getLocales ( ) ) , 'DefaultSite' ) ; $ fields -> addFieldsToTab ( 'Root.Main' , [ ToggleCompositeField :: create ( 'PageTypeBlacklistToggle' , _t ( __CLASS__ . '.PageTypeBlacklistField' , 'Disallow page types?' ) , [ CheckboxSetField :: create ( 'PageTypeBlacklist' , '' , $ this -> getPageTypeMap ( ) ) ] ) -> setHeadingLevel ( 4 ) , HiddenField :: create ( 'ID' , '' , $ this -> ID ) , HiddenField :: create ( 'IsSubsite' , '' , 1 ) ] ) ; // If there are any themes available, add the dropdown $ themes = $ this -> allowedThemes ( ) ; if ( ! empty ( $ themes ) ) { $ fields -> addFieldToTab ( 'Root.Main' , DropdownField :: create ( 'Theme' , $ this -> fieldLabel ( 'Theme' ) , $ this -> allowedThemes ( ) , $ this -> Theme ) -> setEmptyString ( _t ( __CLASS__ . '.ThemeFieldEmptyString' , '-' ) ) , 'PageTypeBlacklistToggle' ) ; } // Targetted by the XHR PJAX JavaScript to reload the subsite list in the CMS $ fields -> fieldByName ( 'Root.Main' ) -> addExtraClass ( 'subsite-model' ) ; // We don't need the Groups many many tab $ fields -> removeByName ( 'Groups' ) ; // Rename the main tab to configuration $ fields -> fieldByName ( 'Root.Main' ) -> setTitle ( _t ( __CLASS__ . '.ConfigurationTab' , 'Configuration' ) ) ; } ) ; return parent :: getCMSFields ( ) ; }
Show the configuration fields for each subsite

@return FieldList
Show the configuration fields for each subsite