public function getCMSFields() { $fields = parent::getCMSFields(); $subsites = DataObject::get('Subsite'); if (!$subsites) { $subsites = new ArrayList(); } else { $subsites = ArrayList::create($subsites->toArray()); } $subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0))); $fields->addFieldToTab('Root.Main', DropdownField::create("CopyContentFromID_SubsiteID", _t('SubsitesVirtualPage.SubsiteField', "Subsite"), $subsites->map('ID', 'Title'))->addExtraClass('subsitestreedropdownfield-chooser no-change-track'), 'CopyContentFromID'); // Setup the linking to the original page. $pageSelectionField = new SubsitesTreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle"); if (Controller::has_curr() && Controller::curr()->getRequest()) { $subsiteID = Controller::curr()->getRequest()->requestVar('CopyContentFromID_SubsiteID'); $pageSelectionField->setSubsiteID($subsiteID); } $fields->replaceField('CopyContentFromID', $pageSelectionField); // Create links back to the original object in the CMS if ($this->CopyContentFromID) { $editLink = "admin/pages/edit/show/{$this->CopyContentFromID}/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID; $linkToContent = "\n\t\t\t\t<a class=\"cmsEditlink\" href=\"{$editLink}\">" . _t('VirtualPage.EDITCONTENT', 'Click here to edit the content') . "</a>"; $fields->removeByName("VirtualPageContentLinkLabel"); $fields->addFieldToTab("Root.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), 'Title'); $linkToContentLabelField->setAllowHTML(true); } $fields->addFieldToTab('Root.Main', TextField::create('CustomMetaTitle', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')), 'MetaTitle'); $fields->addFieldToTab('Root.Main', TextareaField::create('CustomMetaKeywords', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'MetaKeywords'); $fields->addFieldToTab('Root.Main', TextareaField::create('CustomMetaDescription', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'MetaDescription'); $fields->addFieldToTab('Root.Main', TextField::create('CustomExtraMeta', $this->fieldLabel('CustomMetaTitle'))->setDescription(_t('SubsitesVirtualPage.OverrideNote')), 'ExtraMeta'); return $fields; }
/** * Generate the CMS fields from the fields from the original page. */ function getCMSFields($cms = null) { $fields = parent::getCMSFields($cms); // Setup the linking to the original page. $copyContentFromField = new TreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree"); $copyContentFromField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";')); // Setup virtual fields if ($virtualFields = $this->getVirtualFields()) { $roTransformation = new ReadonlyTransformation(); foreach ($virtualFields as $virtualField) { if ($fields->dataFieldByName($virtualField)) { $fields->replaceField($virtualField, $fields->dataFieldByName($virtualField)->transform($roTransformation)); } } } // Add fields to the tab $fields->addFieldToTab("Root.Content.Main", new HeaderField('VirtualPageHeader', _t('VirtualPage.HEADER', "This is a virtual page")), "Title"); $fields->addFieldToTab("Root.Content.Main", $copyContentFromField, "Title"); // Create links back to the original object in the CMS if ($this->CopyContentFromID) { $linkToContent = "<a class=\"cmsEditlink\" href=\"admin/show/{$this->CopyContentFromID}\">" . _t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>"; $fields->addFieldToTab("Root.Content.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), "Title"); $linkToContentLabelField->setAllowHTML(true); } return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $subsites = DataObject::get('Subsite'); if (!$subsites) { $subsites = new DataObjectSet(); } $subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0))); $subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')); $fields->addFieldToTab('Root.Content.Main', $subsiteSelectionField, 'CopyContentFromID'); // Setup the linking to the original page. $pageSelectionField = new SubsitesTreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle"); $pageSelectionField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);')); if (Controller::has_curr() && Controller::curr()->getRequest()) { $subsiteID = Controller::curr()->getRequest()->getVar('CopyContentFromID_SubsiteID'); $pageSelectionField->setSubsiteID($subsiteID); } $fields->replaceField('CopyContentFromID', $pageSelectionField); // Create links back to the original object in the CMS if ($this->CopyContentFromID) { $editLink = "admin/show/{$this->CopyContentFromID}/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID; $linkToContent = "\n\t\t\t\t<a class=\"cmsEditlink\" href=\"{$editLink}\">" . _t('VirtualPage.EDITCONTENT', 'Click here to edit the content') . "</a>"; $fields->removeByName("VirtualPageContentLinkLabel"); $fields->addFieldToTab("Root.Content.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), 'Title'); $linkToContentLabelField->setAllowHTML(true); } $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle'); $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords'); $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription'); $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta'); return $fields; }
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'); return $fields; }
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; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Archived'); $fields->addFieldToTab('Root.Main', new TreeDropdownField('LinkID', 'Link', 'SiteTree')); $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this carousel item?"), new CheckboxField('Archived', ''))); $group->addExtraClass("field special"); $label->addExtraClass("left"); $fields->removeByName('ParentID'); $fields->insertBefore($wrap = new CompositeField($extraLabel = new LabelField('Note', "Note: You will need to create the carousel item before you can add an image")), 'Image'); $wrap->addExtraClass('alignExtraLabel'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Archived'); $fields->removeByName('Sort'); $fields->insertAfter(LinkField::create('LinkID', 'Link'), "Title"); $fields->insertAfter($altText = TextField::create('AltText', 'Alternative text'), "Title"); $altText->setDescription("e.g. Sign up now!"); $fields->addFieldToTab('Root.Main', $group = new CompositeField($label = new LabelField("LabelArchive", "Archive this promotional item?"), new CheckboxField('Archived', ''))); $group->addExtraClass("field special"); $label->addExtraClass("left"); $fields->removeByName('ParentID'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Order'); $fields->removeByName('ProcessInfo'); $fields->removeByName('StopStageID'); $fields->removeByName('StopButton'); $fields->removeByName('ContinueButton'); $fields->removeByName('DecisionPoint'); $fields->removeByName('CaseFinal'); $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header"> <span class="step-label"> <span class="flyout">3</span><span class="arrow"></span> <span class="title">Stage Settings</span> </span> </h3>'), 'Title'); $caseFinalMap = ProcessCase::get()->filter(array('ParentProcessID' => $this->ParentID))->map("ID", "Title")->toArray(); asort($caseFinalMap); $case = ListboxField::create('CaseFinal', 'Final step for these Cases')->setMultiple(true)->setSource($caseFinalMap)->setAttribute('data-placeholder', _t('ProcessAdmin.Cases', 'Cases', 'Placeholder text for a dropdown')); $fields->insertAfter($case, 'Title'); $fields->insertAfter($group = new CompositeField($label = new LabelField('switchLabel', 'Act as Decision Point'), new CheckboxField('DecisionPoint', '')), 'ParentID'); $group->addExtraClass("field special process-noborder"); $label->addExtraClass("left"); $fields->dataFieldByName('Content')->setRows(10); if ($this->ID > 0) { $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p></p>')); $fields->addFieldToTab('Root.Main', $processInfo = new CompositeField($grid = new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo()->sort(array('TypeID' => 'ASC', 'ProcessCaseID' => 'ASC', 'LinksToAnotherStageID' => 'ASC')), $gridConfig = GridFieldConfig_RelationEditor::create()))); $gridConfig->addComponent(new GridFieldSortableRows('Order')); $processInfo->addExtraClass('process-spacing'); $grid->addExtraClass('toggle-grid'); } else { $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p class="message info">Save this stage to add info</p>')); } $fields->insertBefore(new LiteralField('StageTitleInfo', '<h3 class="process-info-header"> <span class="step-label"> <span class="flyout">4</span><span class="arrow"></span> <span class="title">Information</span> </span> </h3>'), 'SaveRecord'); $stopStage = ProcessStopStage::get(); if ($stopStage) { $fields->insertBefore($inner = new CompositeField(new LiteralField('Decision', '<h3>Decision Point</h3>'), new LiteralField('ExplainStop', '<label class="right">Choose a stop stage if you would like this stage to act as a decision point</label>'), $stop = new DropdownField('StopStageID', 'Stop Stage', $stopStage->map('ID', 'Title')), $continue = new TextField('ContinueButton', 'Button: Continue (e.g. "Yes")'), new TextField('StopButton', 'Button: Stop (e.g. "No")')), 'ProcessInfo'); $stop->setEmptyString('No stop after this stage'); $inner->addExtraClass('message special toggle-decide'); $continue->addExtraClass('process-noborder'); $stop->addExtraClass('process-noborder'); } return $fields; }
public function updateCMSFields(FieldList $fields) { // vars $config = SiteConfig::current_site_config(); $owner = $this->owner; // decode data into array $data = json_decode($owner->OpenGraphData, true); // @todo Add repair method if data is missing / corrupt ~ for fringe cases // tab $tab = new Tab('OpenGraph'); // add disabled/error state if `off` if ($data['og:type'] === 'off') { $tab->addExtraClass('error'); } // add the tab $fields->addFieldToTab('Root.Metadata', $tab, 'FullOutput'); // new identity $tab = 'Root.Metadata.OpenGraph'; // add description // type always visible $fields->addFieldsToTab($tab, array(LabelField::create('OpenGraphHeader', '@todo Information</a>')->addExtraClass('information'), DropdownField::create('OpenGraphType', '<a href="http://ogp.me/#types">og:type</a>', self::$types, $data['og:type']))); if ($data['og:type'] !== 'off') { $fields->addFieldsToTab($tab, array(ReadonlyField::create('OpenGraphURL', 'Canonical URL', $owner->AbsoluteLink()), TextField::create('OpenGraphSiteName', 'Site Name', $data['og:site_name'])->setAttribute('placeholder', $config->Title), TextField::create('OpenGraphTitle', 'Page Title', $data['og:title'])->setAttribute('placeholder', $owner->Title), TextareaField::create('OpenGraphDescription', 'Description', $data['og:description'])->setAttribute('placeholder', $owner->GenerateDescription()), UploadField::create('OpenGraphImage', 'Image<pre>type: png/jpg/gif</pre><pre>size: variable *</pre>', $owner->OpenGraphImage)->setAllowedExtensions(array('png', 'jpg', 'jpeg', 'gif'))->setFolderName(self::$SEOOpenGraphUpload . $owner->Title)->setDescription('* <a href="https://developers.facebook.com/docs/sharing/best-practices#images" target="_blank">Facebook image best practices</a>, or use any preferred Open Graph guide.'))); } }
public function getCMSFields($params = null) { //fields that shouldn't be changed once coupon is used $fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints"))))); if (!$this->isInDB()) { $fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints"); } $this->extend("updateCMSFields", $fields, $params); if ($count = $this->getUseCount()) { $fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), HeaderField::create("TotalSavings", sprintf("A total of %s has been saved by customers using this discount.", $this->SavingsTotal), "3"), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton")))); } if ($params && isset($params['forcetype'])) { $valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield; $fields->insertAfter($valuefield, "Type"); $fields->removeByName("Type"); } elseif ($this->Type && (double) $this->{$this->Type}) { $valuefield = $this->Type == "Percent" ? $percentfield : $amountfield; $fields->removeByName("Type"); $fields->insertAfter($valuefield, "ActionTitle"); $fields->replaceField($this->Type, $valuefield->performReadonlyTransformation()); if ($this->Type == "Percent") { $fields->insertAfter($maxamountfield, "Percent"); } } 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) { $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), HeaderField::create("ModelHeading", _t("ProductCategory.MODELSHEADING", "Specify the models for this Product Category"))); $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), LabelField::create("ModelLabel", _t("ProductCategory.MODELSLABEL", "The below entries determine the order of Models, and their associated products, on the Product Category Pages. Also, sets the Models to appear in dropdown on each Product's page."))); $fields->addFieldToTab("Root." . _t('ProductCategory.MODELS', 'Models'), GridField::create('Models', _t("ProductCategory.MODELS", "Models"), $this->owner->ProductModels()->sort('Sort', 'ASC'), $config = GridFieldConfig_RecordEditor::create())); // Add reorder capabilties if ($this->owner->ProductModels()->count() >= 2) { $config->addComponent(new GridFieldOrderableRows('Sort')); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertAfter($gameFormContent = new HTMLEditorField('GameLiveContent', 'Game selection form detail'), 'Content'); $gameFormContent->setRows(20); $regOpen = new CheckboxField('OpenGameReg', ''); $fields->insertBefore($cField = new CompositeField(array($label = new LabelField('OpenGameRegLabel', 'Open game selection (all)'), $regOpen)), 'Content'); $cField->addExtraClass('field'); $regOpen->addExtraClass('mts'); $label->addExtraClass('left'); $groupsMap = array(); foreach (Group::get() as $group) { // Listboxfield values are escaped, use ASCII char instead of » $groupsMap[$group->ID] = $group->getBreadcrumbs(' > '); } asort($groupsMap); $fields->insertBefore(ListboxField::create('OpenGameRegForGroups', "Open game selection for group (limited)")->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')), 'Content'); return $fields; }
/** * Sets up the spam question. Chooses a question at random and adds it to the form * * @param ContactForm */ public function initialize(ContactForm $proxy) { if (sizeof($this->questions)) { $rand = rand(0, sizeof($this->questions) - 1); $q = $this->questions[$rand]; $name = "SimpleQuestion_{$rand}"; $proxy->addField(LabelField::create("SimpleSpamQuestion_label_{$rand}", $this->heading))->addField(TextField::create($name, $q['question'])); $proxy->addOmittedField($name); } }
/** * Adds variations specific fields to the CMS. */ public function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.Variations', array(ListboxField::create("VariationAttributeTypes", _t('ProductVariationsExtension.ATTRIBUTES', "Attributes"), ProductAttributeType::get()->map("ID", "Title")->toArray())->setMultiple(true)->setDescription(_t('ProductVariationsExtension.ATTRIBUTES_DESCRIPTION', "These are fields to indicate the way(s) each variation varies. Once selected, they can be edited on each variation.")), GridField::create("Variations", _t('ProductVariationsExtension.VARIATIONS', "Variations"), $this->owner->Variations(), GridFieldConfig_RecordEditor::create()))); if ($this->owner->Variations()->exists()) { $fields->addFieldToTab('Root.Pricing', LabelField::create('variationspriceinstructinos', _t('ProductVariationsExtension.VARIATIONS_INSTRUCTIONS', "Price - Because you have one or more variations, the price can be set in the \"Variations\" tab."))); $fields->removeFieldFromTab('Root.Pricing', 'BasePrice'); $fields->removeFieldFromTab('Root.Pricing', 'CostPrice'); $fields->removeFieldFromTab('Root.Main', 'InternalItemID'); } }
/** * 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; }
public function updateCMSFields(FieldList $fields) { $fields->removeByName('LastSignificantChange'); $fields->removeByName('ChangeDescription'); if ($this->owner->LastSignificantChange !== NULL) { $dateTime = new DateTime($this->owner->LastSignificantChange); //Put these fields on the top of the First Tab's form $fields->first()->Tabs()->first()->getChildren()->unshift(LabelField::create("infoLastSignificantChange", "<strong>Last Significant change was at: " . "{$dateTime->Format('d/m/Y H:i')}</strong>")); $fields->insertAfter(CheckboxField::create("isSignificantChange", "CLEAR Last Significant change: {$dateTime->Format('d/m/Y H:i')}")->setDescription('Check and save this Record again to clear the Last Significant change date.')->setValue(FALSE), 'infoLastSignificantChange'); $fields->insertAfter(TextField::create('ChangeDescription', 'Description of Changes')->setDescription('This is an automatically generated list of changes to important fields.'), 'isSignificantChange'); } }
function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); $fields->removeByName('SortID'); $fields->removeByName('Archived'); $fields->addFieldToTab('Root.Main', LinkField::create('LinkID', 'Link')); $fields->addFieldToTab('Root.Main', CompositeField::create(array(LabelField::create("LabelArchive", "Archive this carousel item?")->addExtraClass("left"), CheckboxField::create('Archived', '')))->addExtraClass("field special")); $imageField = $fields->dataFieldByName('Image'); if ($imageField) { $imageField->setAllowedFileCategories("image")->setAllowedMaxFileNumber(1); if ($this->Parent() && $this->Parent()->hasMethod("ImageFolder")) { $imageField->setFolderName($this->Parent()->ImageFolder("carousel")); } } return $fields; }
/** * Adds tabs & fields to the CMS. * * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { //// Favicons Tab $tab = 'Root.Metadata.Favicons'; //// Favicon $fields->addFieldsToTab($tab, array(LabelField::create('FaviconDescription', 'Favicons are `favourite icons` used by browsers in a number of ways whenever an icon is necessary e.g. tabs, history, bookmarks, dashboards.<br />@ <a href="https://en.wikipedia.org/wiki/Favicon" target="_blank">Favicon - Wikipedia, the free encyclopedia</a>')->addExtraClass('information'))); //// HTML4 Favicon // check favicon.ico & set status $icoStatus = ReadonlyField::create('HTML4FaviconStatus', 'Favicon ICO<pre>type: ico</pre><pre>size: (multiple)<br />16x16 & 32x32 & 64x64 px</pre>', 'favicon.ico error'); if (Director::fileExists('favicon.ico')) { $icoStatus->setValue('favicon.ico found')->addExtraClass('success favicon'); } else { $icoStatus->setValue('favicon.ico not found')->addExtraClass('error'); } // header & fields $fields->addFieldsToTab($tab, array(HeaderField::create('HTML4FaviconHeader', 'HTML4 <span class="aka">( favicon.ico )</span>'), LabelField::create('HTML4FaviconDescription', 'It is recommended you simply have a `favicon.ico` file in the webroot.')->addExtraClass('information'), $icoStatus)); //// HTML5 Favicon // header & fields $fields->addFieldsToTab($tab, array(HeaderField::create('HTML5FaviconHeader', 'HTML5 <span class="aka">( favicon.png )</span>'), LabelField::create('HTML5FaviconDescription', '@todo Description')->addExtraClass('information'), UploadField::create('HTML5Favicon', 'Favicon PNG<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload))); //// Pinned Icons Tab $tab = 'Root.Metadata.PinnedIcons'; //// Pinned Icons Information $fields->addFieldsToTab($tab, array(LabelField::create('PiniconDescription', 'Pinned icons are OS-specific desktop shortcuts to pages on your website, they allow you to configure additional theming options to make pages appear more `native` / `web-app-y` within the OS.<br />Given they are OS-specific, they (obviously!) have a different format for each one :(')->addExtraClass('information'))); //// Pinned Icon Title // CMS fields $fields->addFieldsToTab($tab, array(HeaderField::create('PiniconTitleHeader', 'Pinned Icon Title <span class="aka">( a.k.a. App Name )</span>'), LabelField::create('PiniconTitleDescription', 'When adding a link to the home screen, the user can choose a caption. By default, this is the bookmarked page title, which is usually fine. However, iOS and Windows 8 let you override this default value.')->addExtraClass('information'), TextField::create('PiniconTitle', 'Application Title')->setAttribute('placeholder', 'default: page title'))); //// iOS Pinned Icon // CMS fields $fields->addFieldsToTab($tab, array(HeaderField::create('IOSPiniconHeader', 'iOS Pinned Icon <span class="aka">( a.k.a. Touch Icons, Web Clips )</span>'), LabelField::create('IOSPiniconDescription', 'iPhone and iPad users can pin your web site on their home screen. The link looks like a native app.<br />@ <a href="https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html" target="_blank">Configuring Web Applications - iOS Developer Library</a>')->addExtraClass('information'), UploadField::create('IOSPinicon', 'iOS Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload)->setDescription('iOS will fill the transparent regions with black by default, so put your own background in!'))); //// Android Pinned Icon // CMS fields $fields->addFieldsToTab($tab, array(HeaderField::create('AndroidPiniconHeader', 'Android Pinned Icon <span class="aka">( a.k.a. Android Chrome Icons, Launcher Icons )</span>'), LabelField::create('AndroidPiniconDescription', 'Add to Homescreen is a also a feature of Android Chrome. Your visitors can mix their natives apps and web bookmarks.<br />@ <a href="https://developer.chrome.com/multidevice/android/installtohomescreen" target="_blank">Add to Homescreen - Google Chrome</a>')->addExtraClass('information'), UploadField::create('AndroidPinicon', 'Android Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload), TextField::create('AndroidPiniconThemeColor', 'Theme Color<pre>type: hex triplet</pre>')->setAttribute('placeholder', 'none')->setAttribute('size', 6)->setMaxLength(6)->setDescription('Starting with Android Lollipop, you can customize the color of the task bar in the switcher.'))); //// Windows Pinned Icon // CMS fields $fields->addFieldsToTab($tab, array(HeaderField::create('WindowsShortcutHeader', 'Windows Pinned Icon <span class="aka">( a.k.a. Windows 8 / Metro Tiles )</span>'), LabelField::create('WindowsShortcutDescription', 'Windows 8 users can pin your web site on their desktop. Your site appears as a tile, just like a native Windows 8 app.<br />@ <a href="https://msdn.microsoft.com/en-us/library/dn455106" target="_blank">Creating custom tiles for IE11 websites (Windows)</a>')->addExtraClass('information'), UploadField::create('WindowsPinicon', 'Windows Icon<pre>type: png</pre><pre>size: 192x192 px</pre>')->setAllowedExtensions(array('png'))->setFolderName(self::$SEOIconsUpload), TextField::create('WindowsPiniconBackgroundColor', 'Background ( Tile ) Color<pre>type: hex triplet</pre>')->setAttribute('placeholder', 'none')->setAttribute('size', 6)->setMaxLength(6))); // @todo Safari Pinned Tab ~ maybe ?? }
/** * Gets the title fields. * * This approach for getting fields for updateCMSFields is to be duplicated through all other modules to reduce complexity. * * @TODO i18n implementation * * @return array */ public function getTitleFields() { return array(LabelField::create('FaviconDescription', 'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href="https://moz.com/learn/seo/title-tag" target="_blank">Title Tag - Learn SEO - Mozilla</a>')->addExtraClass('information'), DropdownField::create('TitleOrder', 'Page Title Order', self::$TitleOrderOptions), TextField::create('TitleSeparator', 'Page Title Separator')->setAttribute('placeholder', self::$TitleSeparatorDefault)->setAttribute('size', 1)->setMaxLength(1)->setDescription('max 1 character'), TextField::create('Title', 'Website Name'), TextField::create('TaglineSeparator', 'Tagline Separator')->setAttribute('placeholder', self::$TaglineSeparatorDefault)->setAttribute('size', 1)->setMaxLength(1)->setDescription('max 1 character'), TextField::create('Tagline', 'Tagline')->setDescription('optional')); }
public function testFieldHasNoNameAttribute() { $field = new LabelField('MyName', 'MyTitle'); $this->assertEquals(trim($field->Field()), '<label id="MyName" class="readonly">MyTitle</label>'); }
/** * @param FieldList $fields */ protected function setDeployConfigurationFields(&$fields) { if (!$this->config()->get('allow_web_editing')) { return; } if ($this->envFileExists()) { $deployConfig = new TextareaField('DeployConfig', 'Deploy config', $this->getEnvironmentConfig()); $deployConfig->setRows(40); $fields->insertAfter($deployConfig, 'Filename'); return; } $warning = 'Warning: This environment doesn\'t have deployment configuration.'; $noDeployConfig = new LabelField('noDeployConfig', $warning); $noDeployConfig->addExtraClass('message warning'); $fields->insertAfter($noDeployConfig, 'Filename'); $createConfigField = new CheckboxField('CreateEnvConfig', 'Create Config'); $createConfigField->setDescription('Would you like to create the capistrano deploy configuration?'); $fields->insertAfter($createConfigField, 'noDeployConfig'); }
function testFieldHasNoNameAttribute() { $field = new LabelField('MyName', 'MyTitle'); $this->assertEquals($field->Field(), '<label id="MyName">MyTitle</label>'); }
public function getHTMLFragments($gridField) { Utilities::include_requirements(); $state = $gridField->State->Milkyway_SS_GridFieldUtils_RangeSlider; $data = ['ColumnCount' => $gridField->getColumnCount()]; $fieldName = 'filterByRange[' . $gridField->getName() . '][' . $this->filterField . '][slider]'; $dbField = singleton($gridField->getModelClass())->obj($this->filterField); $settings = array_merge(['behaviour' => 'drag-tap'], $this->scaffoldSliderSettingsForField($dbField, $gridField->getList()), $this->sliderSettings); if (isset($state->min) && isset($state->max)) { $settings['start'] = [$state->min, $state->max]; } elseif (isset($state->value)) { $settings['value'] = [$state->min, $state->max]; } $data['Slider'] = \RangeSliderField::create($fieldName, null, null, $settings)->addExtraClass('ss-gridfield-range-slider--field'); $data['Button'] = \GridField_FormAction::create($gridField, 'filter', 'Filter', 'filterByRange', null)->addExtraClass('ss-gridfield-range-slider--button')->setAttribute('title', _t('GridField.Filter', 'Filter'))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $this->filterField); if ($this->label !== null) { $data['Label'] = $this->label ?: singleton($gridField->getModelClass())->fieldLabel($this->filterField); } $data['Slider']->inputCallback = function ($fields) use($fieldName, $dbField, $settings, &$data) { foreach ($fields as $field) { $this->modifyFormFieldForDBField($dbField, $field->Render, $settings); if ($field->Render->hasClass('date')) { $data['HasDates'] = true; } } if ($this->navigationLabel) { $fields->unshift(\ArrayData::create(['Render' => \LabelField::create($fieldName . '[label]', $this->navigationLabel)])); } if (isset($data['Label']) && $data['Label']) { $fields->unshift(\ArrayData::create(['Render' => \LabelField::create($fieldName . '--LABEL', $data['Label'])->addExtraClass('ss-gridfield-range-slider--holder-label')])); } }; $data['Slider']->Field(); $data['HideNavigation'] = $this->hideNavigation; return [$this->fragment => \ArrayData::create($data)->renderWith(array_merge((array) $this->template, ['GridField_RangeSlider_Row']))]; }
/** * If there isn't a capistrano env project folder, show options to create one * * @param FieldList $fields */ public function setCreateProjectFolderField(&$fields) { // Check if the capistrano project folder exists if (!$this->Name) { return; } if ($this->projectFolderExists()) { return; } $createFolderNotice = new LabelField('CreateEnvFolderNotice', 'Warning: No Capistrano project folder exists'); $createFolderNotice->addExtraClass('message warning'); $fields->insertBefore($createFolderNotice, 'Name'); $createFolderField = new CheckboxField('CreateEnvFolder', 'Create folder'); $createFolderField->setDescription('Would you like to create the capistrano project folder?'); $fields->insertAfter($createFolderField, 'CreateEnvFolderNotice'); }
function id() { return parent::id() . $this->labelName; }
/** * @return FieldList */ public function getCMSFields() { $self = $this; $this->beforeUpdateCMSFields(function ($fields) use($self) { // define tabs $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form')); $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration')); $fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients')); $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions')); // field editor $fields->addFieldToTab('Root.FormContent', new FieldEditor('Fields', 'Fields', '', $self)); // text to show on complete $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField('OnCompleteMessage', '', _t('UserDefinedForm.ONCOMPLETEMESSAGE', $self->OnCompleteMessage))); $onCompleteFieldSet->addExtraClass('field'); $editor->setRows(3); $label->addExtraClass('left'); // Define config for email recipients $emailRecipientsConfig = GridFieldConfig_RecordEditor::create(10); $emailRecipientsConfig->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient')); // who do we email on submission $emailRecipients = new GridField('EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $self->EmailRecipients(), $emailRecipientsConfig); $emailRecipients->getConfig()->getComponentByType('GridFieldDetailForm')->setItemRequestClass('UserDefinedForm_EmailRecipient_ItemRequest'); $fields->addFieldsToTab('Root.FormOptions', $onCompleteFieldSet); $fields->addFieldToTab('Root.Recipients', $emailRecipients); $fields->addFieldsToTab('Root.FormOptions', $self->getFormOptions()); // view the submissions $submissions = new GridField('Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $self->Submissions()->sort('Created', 'DESC')); // make sure a numeric not a empty string is checked against this int column for SQL server $parentID = !empty($self->ID) ? $self->ID : 0; // get a list of all field names and values used for print and export CSV views of the GridField below. $columnSQL = <<<SQL SELECT "Name", "Title" FROM "SubmittedFormField" LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID" WHERE "SubmittedForm"."ParentID" = '{$parentID}' ORDER BY "Title" ASC SQL; $columns = DB::query($columnSQL)->map(); $config = new GridFieldConfig(); $config->addComponent(new GridFieldToolbarHeader()); $config->addComponent($sort = new GridFieldSortableHeader()); $config->addComponent($filter = new UserFormsGridFieldFilterHeader()); $config->addComponent(new GridFieldDataColumns()); $config->addComponent(new GridFieldEditButton()); $config->addComponent(new GridState_Component()); $config->addComponent(new GridFieldDeleteAction()); $config->addComponent(new GridFieldPageCount('toolbar-header-right')); $config->addComponent($pagination = new GridFieldPaginator(25)); $config->addComponent(new GridFieldDetailForm()); $config->addComponent($export = new GridFieldExportButton()); $config->addComponent($print = new GridFieldPrintButton()); /** * Support for {@link https://github.com/colymba/GridFieldBulkEditingTools} */ if (class_exists('GridFieldBulkManager')) { $config->addComponent(new GridFieldBulkManager()); } $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); // attach every column to the print view form $columns['Created'] = 'Created'; $filter->setColumns($columns); // print configuration $print->setPrintHasHeader(true); $print->setPrintColumns($columns); // export configuration $export->setCsvHasHeader(true); $export->setExportColumns($columns); $submissions->setConfig($config); $fields->addFieldToTab('Root.Submissions', $submissions); $fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server'))); }); $fields = parent::getCMSFields(); return $fields; }
/** * @return FieldList */ public function getCMSFields() { // call updateCMSFields after userforms SiteTree::disableCMSFieldsExtensions(); $fields = parent::getCMSFields(); SiteTree::enableCMSFieldsExtensions(); // define tabs $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form')); $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration')); $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions')); // field editor $fields->addFieldToTab("Root.FormContent", new FieldEditor("Fields", 'Fields', "", $this)); // text to show on complete $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField("OnCompleteMessage", "", _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage))); $onCompleteFieldSet->addExtraClass('field'); $editor->setRows(3); $label->addExtraClass('left'); // Set the summary fields of UserDefinedForm_EmailRecipient dynamically via config system Config::inst()->update('UserDefinedForm_EmailRecipient', 'summary_fields', array('EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From'))); // who do we email on submission $emailRecipients = new GridField("EmailRecipients", _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10)); $emailRecipients->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient')); $fields->addFieldsToTab("Root.FormOptions", $onCompleteFieldSet); $fields->addFieldToTab("Root.FormOptions", $emailRecipients); $fields->addFieldsToTab("Root.FormOptions", $this->getFormOptions()); // view the submissions $submissions = new GridField("Reports", _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $this->Submissions()->sort('Created', 'DESC')); // make sure a numeric not a empty string is checked against this int column for SQL server $parentID = !empty($this->ID) ? $this->ID : 0; // get a list of all field names and values used for print and export CSV views of the GridField below. $columnSQL = <<<SQL SELECT "Name", "Title" FROM "SubmittedFormField" LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID" WHERE "SubmittedForm"."ParentID" = '{$parentID}' ORDER BY "Title" ASC SQL; $columns = DB::query($columnSQL)->map(); $config = new GridFieldConfig(); $config->addComponent(new GridFieldToolbarHeader()); $config->addComponent($sort = new GridFieldSortableHeader()); $config->addComponent($filter = new UserFormsGridFieldFilterHeader()); $config->addComponent(new GridFieldDataColumns()); $config->addComponent(new GridFieldEditButton()); $config->addComponent(new GridState_Component()); $config->addComponent(new GridFieldDeleteAction()); $config->addComponent(new GridFieldPageCount('toolbar-header-right')); $config->addComponent($pagination = new GridFieldPaginator(25)); $config->addComponent(new GridFieldDetailForm()); $config->addComponent($export = new GridFieldExportButton()); $config->addComponent($print = new GridFieldPrintButton()); $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); // attach every column to the print view form $columns['Created'] = 'Created'; $filter->setColumns($columns); // print configuration $print->setPrintHasHeader(true); $print->setPrintColumns($columns); // export configuration $export->setCsvHasHeader(true); $export->setExportColumns($columns); $submissions->setConfig($config); $fields->addFieldToTab("Root.Submissions", $submissions); $fields->addFieldToTab("Root.FormOptions", new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', "Disable Saving Submissions to Server"))); $this->extend('updateCMSFields', $fields); return $fields; }
public function setForm($form) { $result = parent::setForm($form); $this->labelField->setAttribute("for", $this->checkboxField->ID()); return $result; }