public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertBefore(TextareaField::create('Intro', 'Intro'), 'Content'); $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Intro"); $fields->insertBefore($image = UploadField::create('SplashImage', 'Splash Image'), 'Content'); $image->setFolderName('Uploads/Splash-Images'); if ($this->ClassName === "Page" || $this->ClassName === "HomePage") { $fields->insertAfter(HTMLEditorField::create('ExtraContent'), 'Content'); $gridField = new GridField('FeatureItems', 'FeatureItems', $this->FeatureItems()->sort(array('Sort' => 'ASC', 'Archived' => 'ASC')), $config = GridFieldConfig_RelationEditor::create()); $gridField->setModelClass('FeatureItem'); $fields->addFieldToTab('Root.Features', $gridField); $config->addComponent(new GridFieldOrderableRows()); } else { if ($this->ClassName === "CalendarPage") { $content = $fields->dataFieldByName('Content'); $content->addExtraClass('no-pagebreak'); $events = Event::get()->sort(array('StartDateTime' => 'Desc'))->filterByCallback(function ($record) { return !$record->getIsPastEvent(); }); $gridField = new GridField('Event', 'Upcoming Events', $events, $config = GridFieldConfig_RecordEditor::create()); $gridField->setModelClass('Event'); $dataColumns = $config->getComponentByType('GridFieldDataColumns'); $dataColumns->setDisplayFields(array('Title' => 'Title', 'StartDateTime' => 'Date and Time', 'DatesAndTimeframe' => 'Presentation String')); $fields->addFieldToTab('Root.UpcomingEvents', $gridField); } } return $fields; }
protected function generateColorPalette($fieldName, $paletteSetting) { $palette = $this->owner->config()->get($paletteSetting) ? $this->owner->config()->get($paletteSetting) : Config::inst()->get($this->class, $paletteSetting); $field = ColorPaletteField::create($fieldName, $this->owner->fieldLabel($fieldName), ArrayLib::valuekey($palette)); if (Config::inst()->get($this->class, 'colors_can_be_empty')) { $field = $field->setEmptyString('none'); } return $field; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', [ColorPaletteField::create('BackgroundColor', $this->fieldLabel('BackgroundColor'), ['grey-light' => '#F6F6F6', 'white' => '#FFF', 'blue-dark' => '#015790'])], 'Content'); $gridFieldConfig = GridFieldConfig_RecordEditor::create(); $gridFieldConfig->addComponent(new GridFieldOrderableRows('SortOrder')); $field = GridField::create('Galeries', 'Galleries', $this->Galleries()->sort('SortOrder'), $gridFieldConfig); $fields->addFieldToTab("Root.Galleries", $field); return $fields; }
/** * Add cms field for Color db field * @return FieldList */ public function updateCMSFields(FieldList $fields) { $color = $this->owner->Color; $pallete = $this->dominantColorPalette(); $options = array(); $options[$color] = $color; foreach ($pallete as $color) { $options[$color] = $color; } $fields->AddFieldToTab('Root.Main', ColorPaletteField::create($name = 'Color', $title = 'Color', $source = $options, $value = $this->owner->Color)); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Archived'); $fields->removeByName('Sort'); $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this news item?"), new CheckboxField('Archived', ''))); $group->addExtraClass("field special"); $label->addExtraClass("left"); $fields->removeByName('ParentID'); $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title"); return $fields; }
/** * Returns a FieldList of cms form fields that is the main form for editing this DataObject * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); // Hide these from editing $fields->removeByName('ParentID'); $fields->removeByName('Sort'); $image = $fields->dataFieldByName('SplashImage'); $image->setFolderName('Uploads/Splash-Images'); $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title"); $fields->removeByName('HideFromRegionLists'); // Archived $fields->removeByName('Archived'); $fields->addFieldToTab('Root.Main', $group = new CompositeField($labelHide = new LabelField("LabelHideFromRegionLists", "Hide from region lists?"), new CheckboxField('HideFromRegionLists', "e.g. if you need a region for an event that isn't a branch location"), $label = new LabelField("LabelArchive", "Archive this region?"), new CheckboxField('Archived', ''))); $labelHide->addExtraClass("left"); $group->addExtraClass("special field"); $label->addExtraClass("left"); return $fields; }
public function updateCMSFields(FieldList $fields) { $details = $fields->dataFieldByName('Details'); $event = $fields->dataFieldByName('EventPageID'); $cID = Calendar::get_one('Calendar')->ID; $fields->push($calendar = HiddenField::create('CalendarID', 'Calendar')); $calendar->setValue($cID); $fields->insertAfter($event, 'TimeFrameType'); $fields->insertAfter($region = DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title')), 'EventPageID'); $region->setEmptyString(' '); $fields->removeByName('RelatedPage'); $fields->addFieldToTab('Root.Details', TextareaField::create('Intro', 'Intro')); $fields->insertAfter($details, 'Intro'); $fields->addFieldToTab('Root.Brand', ColorPaletteField::create("Colour", "Colour", $this->owner->getPalette())); $fields->insertAfter($splash = UploadField::create('SplashImage', 'Splash Image'), 'Colour'); $fields->insertAfter($small = UploadField::create('SmallImage', 'Small Image'), 'SplashImage'); $splash->setFolderName('Uploads/Splash-Images'); $small->setFolderName('Uploads/Small-Images'); }
/** * Returns a FieldList of cms form fields * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); // Hide these from editing $fields->removeByName('ParentID'); $fields->removeByName('Sort'); //Remove to re-add $fields->removeByName('Type'); $fields->removeByName('LinkLabel'); $content = $fields->dataFieldByName('Content'); $numberToDisplay = $fields->dataFieldByName('NumberToDisplay'); $projectPage = $fields->dataFieldByName('ProjectPageID'); $html = $fields->dataFieldByName('HTML'); $subtitle = $fields->dataFieldByName('SubTitle'); $html->setRows(20); $html->addExtraClass('no-pagebreak'); $link = $fields->dataFieldByName('LinkID'); $image = $fields->dataFieldByName('Image'); $image->setFolderName('Uploads/Small-Images'); $fields->removeByName('Image'); $fields->insertBefore($projectPage, 'Content'); $fields->insertAfter($type = OptionSetField::create("Type", "Type", $this->dbObject('Type')->enumValues()), "Colour"); $type->addExtraClass('inline-short-list'); $fields->insertAfter(ColorPaletteField::create("Colour", "Colour", array('night' => '#333333', 'air' => '#009EE2', 'earth' => ' #79c608', 'passion' => '#b02635', 'people' => '#de347f', 'inspiration' => '#783980')), "Title"); $fields->insertAfter($linkLabel = new TextField("LinkLabel", "Link Label"), "LinkID"); $fields->insertAfter($imageLogin = DisplayLogicWrapper::create($image), 'LinkLabel'); $imageLogin->hideUnless("Type")->isEqualTo("Content"); $html->hideUnless("Type")->isEqualTo("HTML"); $subtitle->hideUnless("Type")->isEqualTo("HTML"); $link->hideUnless("Type")->isEqualTo("Content")->orIf("Type")->isEqualTo("Project"); $linkLabel->hideUnless("LinkID")->isGreaterThan(0)->andIf("Type")->isEqualTo("Content"); $numberToDisplay->hideIf("Type")->isEqualTo("Content")->orIf("Type")->isEqualTo("HTML"); $projectPage->hideUnless("Type")->isEqualTo("Project"); $content->hideUnless("Type")->isEqualTo("Content"); // Archived $fields->removeByName('Archived'); $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this feature?"), new CheckboxField('Archived', ''))); $group->addExtraClass("special field"); $label->addExtraClass("left"); return $fields; }
/** * @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; }