CMS Fields
@return FieldList
343010
public function updateCMSFields(FieldList $fields)
    {
        if (!Permission::check("VIEW_SECTIONS")) {
            return $fields;
        }

        $SectionGrid = GridFieldConfig_RelationEditor::create()
            ->removeComponentsByType('GridFieldAddNewButton')
            ->addComponent(new GridFieldAddNewMultiClass())
            ->addComponent(new GridFieldOrderableRows());

        $SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')
            ->setSearchFields(array('AdminTitle', 'MenuTitle'))
            ->setResultsFormat('$AdminTitle - $Type');

        $AvailableTypes = $this->AvailableSectionTypes();

        foreach ($AvailableTypes as $key => $value) {
            if($value['selectable_option'] && !$value['limit_reached']){
                $AvailableTypes[$key] = $value['type'];
            }
        }

        $SectionGrid->getComponentByType('GridFieldAddNewMultiClass')
            ->setClasses($AvailableTypes);

        // Limit total sections
        $LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
        if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
            // remove the buttons if we don't want to allow more records to be added/created
            $SectionGrid->removeComponentsByType('GridFieldAddNewButton');
            $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
            $SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
        }

        if (!Permission::check("LINK_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
        }

        if (!Permission::check("REORDER_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldOrderableRows');
        }

        if (!Permission::check("UNLINK_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldDeleteAction');
        }

        $fields->addFieldToTab(
            'Root.Section',
            GridField::create(
                'Sections',
                'Current Section(s)',
                $this->owner->Sections(),
                $SectionGrid
            )
        );

        $fields->addFieldToTab(
            'Root.Preview',
            UploadField::create(
                'PreviewImage',
                'Preview image'
            )->setFolderName('Preview')
        );

        return $fields;
    }
1176087
public function getFieldList()
    {
        // Get additional fields of current structure
        $fields = dbQuery('\samson\cms\web\field\CMSField')
            ->join('\samson\cms\CMSNavField')
            ->cond('StructureID', $this->id)
            ->exec();

        // Create list view
        $items = '';

        // If structure has additional fields then add them to list
        if (sizeof($fields)) {
            foreach ($fields as $field) {
                $items .= m('structure')->view('form/field/field_item')->field($field)->structure($this)->output();
            }
        } else {
            // Add empty row
            $items = m('structure')->view('form/field/empty_field')->output();
        }

        // Return items view
        return $items;
    }
1242599
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('OpeningHoursSpecification');
        $fields->addFieldsToTab(
            'Root.Main',
            array(
                TextField::create(
                    'Address',
                    _t('SchemaPlace.PAYMENTACCEPTED', 'Address')
                ),
                TextField::create(
                    'BranchCode',
                    _t('SchemaPlace.PRICERANGE', 'Branch code')
                ),
                GridField::create(
                    'OpeningHoursSpecification',
                    _t('SchemaPlace.OPENINGHOURSSPECIFICATION', 'Opening hours specification'),
                    $this->OpeningHoursSpecification(),
                    GridFieldConfig_RelationEditor::create()
                )
            )
        );
        return $fields;
    }
667253
public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function ($fields) {
            /** @var FieldList $fields */
            $fields->removeByName([
                'Sort',
                'AccordionID',
            ]);

            $fields->dataFieldByName('Image')
                ->setFolderName('Uploads/Elements/Accordions');
        });

        return parent::getCMSFields();
    }
1056399
public function updateCMSFields(FieldList $fields)
    {
        $owner = $this->owner;
        $fields->addFieldToTab(
            "Root.Main",
            HiddenField::create(
                'SubsiteID',
                'SubsiteID',
                Subsite::currentSubsiteID()
            )
        );
        return $fields;
    }
484825
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName(array(
            'SortOrder',
            'PhotoGalleryID',
            'ElementLinkID',
        ));
        $image = $fields->dataFieldByName('Image')->setFolderName('Uploads/Elements/PhotoGallery/');
        $fields->insertBefore($image, 'Content');

        // so if anything depends on PageLink it doesn't flake out
        $fields->replaceField('PageLink', new LiteralField('PageLink', ''));

        return $fields;
    }
1252702
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Field Objects:
        
        $fields->fieldByName('Root.Options.TitleOptions')->push(
            CheckboxField::create(
                'HidePageTitle',
                _t(__CLASS__ . '.HIDETITLEOFPAGE', 'Hide title of page')
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
795111
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Content');
        if (Director::isDev()) {
            $fields->addFieldsToTab(
                'Root.Developer',
                array(
                    LiteralField::create(
                        'DeveloperNote',
                        '<p class="message warning">'._t('Placeable.DEVNOTE', 'This tab is only visible during development and is intended to help debug.').'</p>'
                    ),
                    GridField::create(
                        'Regions',
                        _t('PlaceablePage.SECTIONS', 'Regions'),
                        $this->Regions(),
                        GridFieldConfig_RecordEditor::create()
                    )
                )
            );
        }
        foreach ($this->PageFields as $region) {
            $fields->addFieldToTab(
                "Root.{$region->Type}",
                HeaderField::create(
                    "header[$region->Type]",
                    $region->Title
                )
            );
            foreach ($region->Fields as $field) {
                $fields->addFieldToTab(
                    "Root.{$region->Type}",
                    $field
                );
            }
            foreach ($region->Blocks as $Block) {
                $blockfields = CompositeField::create(
                    HeaderField::create(
                        "header[$Block->Type]",
                        $Block->Title
                    )
                );
                foreach ($Block->Fields as $field) {
                    $blockfields->push($field);
                }
                $fields->addFieldToTab(
                    "Root.{$region->Type}",
                    $blockfields
                );
            }
        }
        return $fields;
    }
324409
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Field Objects:
        
        $fields->fieldByName('Root.Options.TitleOptions')->push(
            CheckboxField::create(
                'UseLevelTitle',
                $this->fieldLabel('UseLevelTitle')
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
1229538
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Create Main Tab:
        
        $fields->findOrMakeTab('Root.Main', $this->fieldLabel('Main'));
        
        // Create Class Field:
        
        if (!$this->isInDB()) {
            
            // Define Placeholder:
            
            $placeholder = _t(__CLASS__ . '.SELECTTYPETOCREATE', '(Select type to create)');
            
            // Create Dropdown Field:
            
            $classField = DropdownField::create(
                'ClassName',
                $this->fieldLabel('ClassName'),
                $this->getClassNameOptions()
            )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder);
            
        } else {
            
            // Create Read-Only Field:
            
            $classField = ReadonlyField::create(
                'Type',
                $this->fieldLabel('Type')
            );
            
        }
        
        // Add Class Field to Main Tab:
        
        $fields->addFieldToTab('Root.Main', $classField);
        
        // Apply Extensions:
        
        if ($this->isInDB()) {
            
            // Extend Field Objects:
            
            $this->extend('updateCMSFields', $fields);
            
        }
        
        // Answer Field Objects:
        
        return $fields;
    }
1300629
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            'Root.Main',
            array(
                DropdownField::create(
                    'ClassName',
                    _t('Placeable.TYPE', 'Type'),
                    singleton('RegionObject_Preset')->SubClassNames
                )->setEmptyString(_t('Placeable.NONE', 'None'))
            )
        );

        $fields->removeByName('PageTypes');
        $fields->addFieldsToTab(
            'Root.PageTypes',
            array(
                LabelField::create(
                    'PageTypesDescription',
                    _t('RegionObject_Preset.PAGETYPESDESCRIPTION', 'List of all page types that use this use this preset.')
                ),
                GridField::create(
                    'PageTypes',
                    _t('RegionObject_Preset.PAGETYPES', 'Page Types'),
                    $this->Objects(),
                    GridFieldConfig_Base::create()
                )
            )
        );

        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
729813
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                UploadField::create(
                    'Image',
                    $this->fieldLabel('Image')
                )->setAllowedFileCategories('image')->setFolderName($this->getAssetFolder()),
                HTMLEditorField::create(
                    'Caption',
                    $this->fieldLabel('Caption')
                )->setRows(10)
            ],
            'LinkTo'
        );
        
        // Create Options Fields:
        
        $fields->addFieldToTab(
            'Root.Options',
            FieldSection::create(
                'SlideOptions',
                $this->fieldLabel('SlideOptions'),
                [
                    CheckboxField::create(
                        'HideTitle',
                        $this->fieldLabel('HideTitle')
                    ),
                    CheckboxField::create(
                        'HideImage',
                        $this->fieldLabel('HideImage')
                    ),
                    CheckboxField::create(
                        'HideCaption',
                        $this->fieldLabel('HideCaption')
                    ),
                    CheckboxField::create(
                        'LinkDisabled',
                        $this->fieldLabel('LinkDisabled')
                    ),
                    CheckboxField::create(
                        'TitleAfterCaption',
                        $this->fieldLabel('TitleAfterCaption')
                    ),
                    CheckboxField::create(
                        'LinkInFooter',
                        $this->fieldLabel('LinkInFooter')
                    ),
                    CheckboxField::create(
                        'ButtonLink',
                        $this->fieldLabel('ButtonLink')
                    ),
                    TextField::create(
                        'ButtonLabel',
                        $this->fieldLabel('ButtonLabel')
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
224008
public function getCMSFields()
    {
        // PHP 5.3 only
        $self = $this;
        $this->beforeUpdateCMSFields(function (FieldList $fields) use ($self) {
            $fields->removeFieldsFromTab(
                'Root.Main',
                array('KeyValuePairs', 'SortBy', 'SortByDirection')
            );
            // Don't put the GridField for documents in until the set has been created
            if (!$self->isInDB()) {
                $fields->addFieldToTab(
                    'Root.Main',
                    LiteralField::create(
                        'GridFieldNotice',
                        '<p class="message warning">' . _t(
                            'DMSDocumentSet.GRIDFIELD_NOTICE',
                            'Managing documents will be available once you have created this document set.'
                        ) . '</p>'
                    ),
                    'Title'
                );
            } else {
                $fields->removeByName('DocumentSetSort');
                // Document listing
                $gridFieldConfig = GridFieldConfig::create()
                    ->addComponents(
                        new GridFieldButtonRow('before'),
                        new GridFieldToolbarHeader(),
                        new GridFieldFilterHeader(),
                        new GridFieldSortableHeader(),
                        new GridFieldDataColumns(),
                        new DMSGridFieldEditButton(),
                        // Special delete dialog to handle custom behaviour of unlinking and deleting
                        new GridFieldDeleteAction(true),
                        new GridFieldDetailForm()
                    );

                if (class_exists('GridFieldPaginatorWithShowAll')) {
                    $paginatorComponent = new GridFieldPaginatorWithShowAll(15);
                } else {
                    $paginatorComponent = new GridFieldPaginator(15);
                }
                $gridFieldConfig->addComponent($paginatorComponent);

                if (class_exists('GridFieldSortableRows')) {
                    $gridFieldConfig->addComponent(new GridFieldSortableRows('DocumentSort'));
                } elseif (class_exists('GridFieldOrderableRows')) {
                    $gridFieldConfig->addComponent(new GridFieldOrderableRows('DocumentSort'));
                }

                // Don't show which page this is if we're already editing within a page context
                if (Controller::curr() instanceof CMSPageEditController) {
                    $fields->removeByName('PageID');
                } else {
                    $fields->fieldByName('Root.Main.PageID')->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
                }

                // Don't show which page this is if we're already editing within a page context
                if (Controller::curr() instanceof CMSPageEditController) {
                    $fields->removeByName('PageID');
                } else {
                    $fields->fieldByName('Root.Main.PageID')->setTitle(_t('DMSDocumentSet.SHOWONPAGE', 'Show on page'));
                }

                $gridFieldConfig->getComponentByType('GridFieldDataColumns')
                    ->setDisplayFields($self->getDocumentDisplayFields())
                    ->setFieldCasting(array('LastEdited' => 'Datetime->Ago'))
                    ->setFieldFormatting(
                        array(
                            'FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\''
                                . ' href=\'$Link\'>$FilenameWithoutID</a>',
                            'ManuallyAdded' => function ($value) {
                                if ($value) {
                                    return _t('DMSDocumentSet.MANUAL', 'Manually');
                                }
                                return _t('DMSDocumentSet.QUERYBUILDER', 'Query Builder');
                            }
                        )
                    );

                // Override delete functionality with this class
                $gridFieldConfig->getComponentByType('GridFieldDetailForm')
                    ->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');
                $gridField = GridField::create(
                    'Documents',
                    false,
                    $self->Documents(),
                    $gridFieldConfig
                );
                $gridField->setModelClass('DMSDocument');
                $gridField->addExtraClass('documents');

                $gridFieldConfig->addComponent(
                    $addNewButton = new DMSGridFieldAddNewButton('buttons-before-left'),
                    'GridFieldExportButton'
                );
                $addNewButton->setDocumentSetId($self->ID);

                $fields->removeByName('Documents');
                $fields->addFieldsToTab(
                    'Root.Main',
                    array(
                        $gridField,
                        HiddenField::create('DMSShortcodeHandlerKey', false, DMS::inst()->getShortcodeHandlerKey())
                    )
                );
                $self->addQueryFields($fields);
            }
        });
        $this->addRequirements();
        return parent::getCMSFields();
    }
1330486
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Remove Field Objects:
        
        $fields->removeFieldsFromTab('Root.Main', ['Content', 'Metadata']);
        
        // Modify Field Objects:
        
        $fields->dataFieldByName('MenuTitle')->addExtraClass('hidden');
        
        // Answer Field Objects:
        
        return $fields;
    }
309624
public function getCMSFields()
    {
        $fields = FieldList::create(
            TabSet::create(
                'Root',
                Tab::create('Main')
            )
            ->setTitle(_t(__CLASS__ . '.TABMAIN', 'Main'))
        );

        $fields->addFieldToTab(
            'Root.Main',
            GridField::create(
                'Links',
                _t(__CLASS__ . '.FIELDLINKS', 'Links'),
                $this->Links,
                GridFieldConfig_RecordEditor::create()
                    ->addComponent(new GridFieldOrderableRows('Sort'))
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
701721
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                DropdownField::create(
                    'FormPageID',
                    'Select a page',
                    UserDefinedForm::get()->map('ID', 'Title')
                )
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
8869
protected function getFields() {
        if (!$this->_fields) {
            $this->_fields = new FieldList(
                $this->version,
                $this->solution['assistantSid'],
                $this->solution['sid']
            );
        }

        return $this->_fields;
    }