/** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $hiddenFields = $this->config()->get('hideCMSInputs'); // short title? if (!in_array('AlternativeTitle', $hiddenFields)) { $fields->addFieldToTab('Root.Main', TextField::create('AlternativeTitle', 'Alternative Title'), 'URLSegment'); } // do we want an intro? if (!in_array('Intro', $hiddenFields)) { $fields->addFieldToTab('Root.Main', TextareaField::create('Intro', 'Intro'), 'Content'); } // add an image if (!in_array('Image', $hiddenFields)) { $fields->addFieldToTab('Root.Main', UploadField::create('ImageID', 'Image')->setAllowedFileCategories('image')->setAllowedMaxFileNumber(1), 'Content'); } // do we use a section color? if (!in_array('Color', $hiddenFields)) { // default is this brand color. $field = NoticeMessage::create('The brand colors have not been defined yet.'); // usually we replace this with the color palette. if (BrandColors::get()->count() > 0) { $field = ColorPaletteField::create('Color', 'Color', BrandColors::get()->map('BrandColor', 'ColorName'))->setRightTitle('Please select a brand color.'); } $fields->addFieldToTab('Root.Main', $field, 'Content'); } // It will repalce Content area field to notice message field, or nothing at the end. if ($this->config()->get('useBlocksModule')) { // move the block related fields over $fields->addFieldsToTab('Root.Main', $fields->findOrMakeTab('Root.Blocks')->Fields(), 'Content'); // now we really don't need the content field anymore. $fields->removeByName('Content'); // remove the blocks tab $fields->removeByName('Root.Blocks'); } if ($this->config()->get('hideContentField')) { $fields->removebyName('Content'); } return $fields; }
/** * @param FieldList */ public function updateCMSFields(FieldList $fields) { // add a gridfield for the management of the files $fields->addFieldsToTab('Root.Brand Colors', GridField::create('BrandColors', 'Brand colors', BrandColors::get(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldSortableRows('Sort')))); return $fields; }