public function updateSettingsFields(FieldList $fields) { $changeFreq = Singleton('Page')->dbObject('ChangeFreq')->enumValues(); $fields->addFieldToTab('Root.Settings', DropDownField::create('ChangeFreq', 'Change Frequency', $changeFreq)); $priority = Singleton('Page')->dbObject('Priority')->enumValues(); $fields->addFieldToTab('Root.Settings', DropDownField::create('Priority', 'Priority', $priority)); }
public function getCMSFields() { $fields = FieldList::create(new TabSet($name = 'Root', new Tab($title = 'Main', HeaderField::create('ContactHD', 'Contact Information'), TextField::create('Title', 'Name'), TextField::create('Phone'), EmailField::create('Email', 'Email'), TextField::create('Website')->setAttribute('placeholder', 'http://'), DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))->setEmptyString('-- select --'), CheckboxField::create('ShowInLocator', 'Show in results')->setDescription('Location will be included in results list'), CheckboxField::create('Featured')->setDescription('Location will show at/near the top of the results list')))); // allow to be extended via DataExtension $this->extend('updateCMSFields', $fields); // override Suburb field name $fields->dataFieldByName('Suburb')->setTitle('City'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $display_types = array('Categories' => 'All Root Categories', 'Category' => 'One Categories Children', 'Products' => 'All Products'); $fields->addFieldToTab('Root.Main', DropDownField::create('Display', 'What will this catalog display?', $display_types), 'Content'); if ($this->Display == 'Category') { $fields->addFieldToTab('Root.Main', TreeDropdownField::create("CategoryID", "Choose a category:", "ProductCategory")->setLabelField("Title"), 'Content'); } $fields->removeByName('Content'); return $fields; }
public function createFields() { $order = $this->order; $member = $this->customer; //Payment fields $supported_methods = PaymentProcessor::get_supported_methods(); $source = array(); foreach ($supported_methods as $methodName) { $methodConfig = PaymentFactory::get_factory_config($methodName); $source[$methodName] = $methodConfig['title']; } $outstanding = $order->TotalOutstanding()->Nice(); $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), LiteralField::create('RepayLit', "<p>Process a payment for the oustanding amount: {$outstanding}</p>"), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields'); $fields = FieldList::create($paymentFields); $this->extend('updateFields', $fields); $fields->setForm($this); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); // remove Main tab $fields->removeByName('Main'); // create and populate Info tab $fields->addFieldsToTab('Root.Info', array(HeaderField::create('InfoHeader', 'Contact Information'), TextField::create('Website'), TextField::create('EmailAddress'), TextField::create('Phone'))); // change label of Suburb from Addressable to City $fields->removeByName('Suburb'); $fields->insertBefore(TextField::create('Suburb', 'City'), 'State'); // If categories have been created, show category drop down if (LocationCategory::get()->Count() > 0) { $fields->insertAfter(DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))->setEmptyString('-- select --'), 'Phone'); } // move Title and ShowInLocator fields to Address tab from Addressable $fields->insertAfter(TextField::create('Title'), 'AddressHeader'); $fields->insertAfter(CheckboxField::create('Featured', 'Featured'), 'Title'); $fields->insertAfter(CheckboxField::create('ShowInLocator', 'Show on Map'), 'Country'); // allow to be extended via DataExtension $this->extend('updateCMSFields', $fields); return $fields; }
public function Form() { $genres = $this->__getGenres(); $clean = parent::__convertAndCleanList($genres, $pipe = '|'); $genres != null ? $genresJson = json_encode($clean) : json_encode(array("Comedy", "Drama", "Horror", "Science Fiction", "Comic/Super Heroes", "Action", "Thriller", "Crime", "Documentary", "Family", "Animated", "Romance", "Adventure", "War", "Sitcom")); Requirements::customScript(' $("#Form_Form_Seasons").tagit({ singleFieldDelimiter: " | ", allowSpaces: true, availableTags: ["Season 1", "Season 2", "Season 3", "Season 4", "Season 5", "Season 6", "Season 7", "Season 8", "Season 9" , "Season 10", "Season 11", "Season 12", "Season 13", "Season 14", "Season 15", "Season 16"] }); $("#Form_Form_Genre").tagit({ singleFieldDelimiter: " | ", availableTags: ' . $genresJson . ' }); '); //create source arrays to swap out on form load $filmarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'screener' => 'SCR/SCREENER/DVDSCR/DVDSCREENER/BDSCR', 'cam' => 'CAMRip/CAM/TS/TELESYNC', 'vod' => 'VODRip/VODR', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL'); $tvarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'HDTV' => 'HD TV', 'SDTV' => 'SD TV', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL'); //include js $keywords = $this->__getKeywords(); if ($keywords != null) { $clean = parent::__convertAndCleanList($keywords, $pipe = ','); $json = json_encode($clean); // turn into json array for jquery library Requirements::customScript(' $("#Form_Form_keywords").tagit({ singleFieldDelimiter: " , ", allowSpaces: true, fieldName: "keywordsField", availableTags: ' . $json . ' }); '); } else { Requirements::customScript(' $("#Form_Form_keywords").tagit({ singleFieldDelimiter: " , ", allowSpaces: true, }); '); } $action = Controller::curr()->getRequest()->param('Action'); $id = (int) Controller::curr()->getRequest()->param('ID'); $automap = $id ? $automap = Catalogue::get()->byID($id) : false; $submitCaption = $automap ? 'Edit' : 'Add'; $sourceArr = $filmarr; if (isset($automap->Video_type)) { $automap->Video_type == 'film' ? $sourceArr = $filmarr : ($sourceArr = $tvarr); } // Create fields $fields = FieldList::create(TextField::create('Video_title', 'Video Title'), DropDownField::create('Video_type', 'Type of Video', array('series' => 'Series (TV)', 'film' => 'Film'))->setEmptyString('Select type of media'), TextField::create('Genre', 'Genre')->setDescription('Select a genre by typing a keyword e.g. Comedy'), TextField::create('keywords', 'Keywords')->setDescription('Add a keyword/tag to the title e.g. Marvel'), TextField::create('trilogy', 'Is this a Trilogy?')->setDescription('Add a trilogy name e.g. "X-Men" or "Wolverine"'), TextField::create('Seasons', 'Seasons')->setDescription('Select a Season or type Seasons owned e.g. Season 1'), DropDownField::create('Status', 'Current Status of download', array('Downloaded' => 'Downloaded - file complete', 'Downloading' => 'Dowloading - in progress', 'Wanted' => 'Wanted - need a copy of', 'No Torrents' => 'No Torrents - cannot find video'))->setEmptyString('Select status'), DropDownField::create('Source', 'Source of download', $sourceArr)->setEmptyString('Select source'), DropDownField::create('Quality', 'Resolution of download (quality)', array('4k' => '4k', '1440p' => '1440p', '1080p' => '1080p', '720p' => '720p', '420p' => '420p', '320p' => '320p'))->setEmptyString('Select quality'), HiddenField::create('Owner', '', Member::currentUserID()), HiddenField::create('Comments'), HiddenField::create('imdbID'), HiddenField::create('Year'), TextareaField::create('CommentsEnter', 'Enter new comments on new line'), HiddenField::create('Poster'), HiddenField::create('ID', 'ID')->setValue($id)); $actions = FieldList::create(FormAction::create('submit', $submitCaption)); $validator = RequiredFields::create('Video_title'); $form = Form::create($this, 'Form', $fields, $actions, $validator); $form->type = $submitCaption; //are we in edit or add mode, pass it to view if ($automap) { $form->loadDataFrom($automap); } return $form; }
/** * {@inheritdoc} */ public function getCMSFields() { Requirements::css(BLOGGER_DIR . '/css/cms.css'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); $self =& $this; $this->beforeUpdateCMSFields(function ($fields) use($self) { $uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image')); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); /** * @var FieldList $fields */ $fields->insertAfter($uploadField, 'Content'); $summary = HtmlEditorField::create('Summary', false); $summary->setRows(5); $summary->setDescription(_t('BlogPost.SUMMARY_DESCRIPTION', 'If no summary is specified the first 30 words will be used.')); $summaryHolder = ToggleCompositeField::create('CustomSummary', _t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), array($summary)); $summaryHolder->setHeadingLevel(4); $summaryHolder->addExtraClass('custom-summary'); $fields->insertAfter($summaryHolder, 'FeaturedImage'); $fields->push(HiddenField::create('MenuTitle')); $urlSegment = $fields->dataFieldByName('URLSegment'); $urlSegment->setURLPrefix($self->Parent()->RelativeLink()); $fields->removeFieldsFromTab('Root.Main', array('MenuTitle', 'URLSegment')); $authorField = ListboxField::create('Authors', _t('BlogPost.Authors', 'Authors'), Member::get()->map()->toArray())->setMultiple(true); $authorNames = TextField::create('AuthorNames', _t('BlogPost.AdditionalCredits', 'Additional Credits'), null, 1024); $authorNames->setDescription('If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'); if (!$self->canEditAuthors()) { $authorField = $authorField->performDisabledTransformation(); $authorNames = $authorNames->performDisabledTransformation(); } $publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date')); $publishDate->getDateField()->setConfig('showcalendar', true); // Get categories and tags $parent = $self->Parent(); $categories = $parent instanceof Blog ? $parent->Categories()->exclude('CatID', 0) : BlogCategory::get()->exclude('CatID', 0); $list = array(); foreach ($categories->sort('CatID, Title ASC') as $cat) { $list[$cat->ID] = sprintf('%s/%s', $cat->Cat()->Title, $cat->Title); } $val = ''; if ($this->Categories()->count() > 0) { $val = $this->Categories()->first()->ID; } $options = BlogAdminSidebar::create($publishDate, $urlSegment, $catField = DropDownField::create('Category', 'Category', $list, $value = $val)->setEmptyString('(select one)'), $authorField, $authorNames)->setTitle('Post Options'); $fields->insertBefore($options, 'Root'); }); $fields = parent::getCMSFields(); $fields->fieldByName('Root')->setTemplate('TabSet_holder'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ModuleAreaID'); $fields->removeByName('SortOrder'); $fields->removeByName('URLSegment'); if ($this->ClassName == 'ContentModule') { $fields->addFieldToTab('Root.Main', DropDownField::create('ClassName', 'Choose Module Type', $this->getClassesForDropdown())); $fields->addFieldToTab('Root.Main', LiteralField::create('ClassNameMessage', '<div class="message">You can add content after saving for the first time.</div>')); Config::inst()->update('ContentModule', 'better_buttons_enabled', false); } else { $fields->addFieldToTab('Root.Settings', DropDownField::create('ClassName', 'Module Type', $this->getClassesForDropdown())); } return $fields; }
public function createFields() { $order = $this->order; $member = $this->customer; //Personal details fields if (!$member->ID || $member->Password == '') { $link = $this->controller->Link(); $note = _t('CheckoutPage.NOTE', 'NOTE:'); $passwd = _t('CheckoutPage.PLEASE_CHOOSE_PASSWORD', 'Please choose a password, so you can login and check your order history in the future.'); $mber = sprintf(_t('CheckoutPage.ALREADY_MEMBER', 'If you are already a member please %s log in. %s'), "<a href=\"Security/login?BackURL={$link}\">", '</a>'); $personalFields = CompositeField::create(new HeaderField(_t('CheckoutPage.ACCOUNT', "Account"), 3), new CompositeField(EmailField::create('Email', _t('CheckoutPage.EMAIL', 'Email'))->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_EMAIL_ADDRESS', "Please enter your email address."))), new CompositeField(new FieldGroup(new ConfirmedPasswordField('Password', _t('CheckoutPage.PASSWORD', "Password")))), new CompositeField(new LiteralField('AccountInfo', "\r\n\t\t\t\t\t\t<p class=\"alert alert-info\">\r\n\t\t\t\t\t\t\t<strong class=\"alert-heading\">{$note}</strong>\r\n\t\t\t\t\t\t\t{$passwd} <br /><br />\r\n\t\t\t\t\t\t\t{$mber}\r\n\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t")))->setID('PersonalDetails')->setName('PersonaDetails'); } //Order item fields $items = $order->Items(); $itemFields = CompositeField::create()->setName('ItemsFields'); if ($items) { foreach ($items as $item) { $itemFields->push(new OrderForm_ItemField($item)); } } //Order modifications fields $subTotalModsFields = CompositeField::create()->setName('SubTotalModificationsFields'); $subTotalMods = $order->SubTotalModifications(); if ($subTotalMods && $subTotalMods->exists()) { foreach ($subTotalMods as $modification) { $modFields = $modification->getFormFields(); foreach ($modFields as $field) { $subTotalModsFields->push($field); } } } $totalModsFields = CompositeField::create()->setName('TotalModificationsFields'); $totalMods = $order->TotalModifications(); if ($totalMods && $totalMods->exists()) { foreach ($totalMods as $modification) { $modFields = $modification->getFormFields(); foreach ($modFields as $field) { $totalModsFields->push($field); } } } //Payment fields $supported_methods = PaymentProcessor::get_supported_methods(); $source = array(); foreach ($supported_methods as $methodName) { $methodConfig = PaymentFactory::get_factory_config($methodName); $source[$methodName] = $methodConfig['title']; } $paymentFields = CompositeField::create(new HeaderField(_t('CheckoutPage.PAYMENT', "Payment"), 3), DropDownField::create('PaymentMethod', 'Select Payment Method', $source)->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method.")))->setName('PaymentFields'); $fields = FieldList::create($itemFields, $subTotalModsFields, $totalModsFields, $notesFields = CompositeField::create(TextareaField::create('Notes', _t('CheckoutPage.NOTES_ABOUT_ORDER', "Notes about this order")))->setName('NotesFields'), $paymentFields); if (isset($personalFields)) { $fields->push($personalFields); } $this->extend('updateFields', $fields); $fields->setForm($this); return $fields; }