/** * @param Controller $controller * @param String $method * @param string $suggestURL */ public function __construct($controller, $method, $suggestURL = '') { $searchField = TextField::create('q', ''); $searchField->setAttribute('placeholder', _t('ShopSearch.SEARCH', 'Search')); if ($suggestURL) { $searchField->setAttribute('data-suggest-url', $suggestURL); } $fields = FieldList::create($searchField); if (!self::config()->disable_category_dropdown) { $cats = ShopSearch::get_category_hierarchy(0, '', self::config()->category_max_depth); $catField = DropdownField::create(self::get_category_field(), '', $cats, Session::get('LastSearchCatID')); $emptyString = self::config()->category_empty_string; if ($emptyString !== 'NONE') { $catField->setEmptyString(_t('ShopSearch.' . $emptyString, $emptyString)); } $fields->push($catField); } parent::__construct($controller, $method, $fields, FieldList::create(array(FormAction::create('results', _t('ShopSearch.GO', 'Go'))))); $this->setFormMethod('GET'); $this->disableSecurityToken(); if ($c = self::config()->css_classes) { $this->addExtraClass($c); } Requirements::css(SHOP_SEARCH_FOLDER . '/css/ShopSearch.css'); if (Config::inst()->get('ShopSearch', 'suggest_enabled')) { Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.suggest.js'); Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.js'); } }
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; }
public function FieldHolder($properties = array()) { Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css'); Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js'); if ($this->object && $this->object->ID) { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); if (strlen($this->object->SourceURL)) { $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title')); $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width')); $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height')); $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', ''); $properties['Type'] = HiddenField::create($this->getName() . '[type]', ''); $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', ''); $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description')); $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class')); foreach ($properties as $key => $field) { if ($key == 'ObjectTitle') { $key = 'Title'; } elseif ($key == 'ObjectDescription') { $key = 'Description'; } $field->setValue($this->object->{$key}); } if ($this->object->ThumbURL) { $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />'); } } } else { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); } $field = parent::FieldHolder($properties); return $field; }
public function updateCMSFields(FieldList $fields) { $fields->insertBefore(new Tab('MembershipDetails', 'Membership Details'), 'Main'); //move first and ;astname $fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('FirstName')); $fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('Surname')); $fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('Email')); $fields->addFieldToTab('Root.MembershipDetails', $region = DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title'))); $region->setEmptyString(' '); $fields->addFieldToTab('Root.MembershipDetails', DropdownField::create('MembershipStatus', 'Membership Status', $this->owner->dbObject('MembershipStatus')->enumValues())); $fields->addFieldToTab('Root.MembershipDetails', $expiry = DateField::create('ExpiryDate')); $fields->addFieldToTab('Root.MembershipDetails', DropdownField::create('Discount', 'Discount', $this->owner->dbObject('Discount')->enumValues())); $fields->addFieldToTab('Root.MembershipDetails', $discountExpiry = DateField::create('DiscountExpiryDate')); $fields->addFieldToTab('Root.MembershipDetails', $joined = DateField::create('JoinedDate')); $fields->addFieldToTab('Root.MembershipDetails', TextareaField::create('NotesForMember')); if ($this->owner->MembershipStatus !== "Not applied") { $fields->addFieldToTab('Root.MembershipDetails', TextField::create('MemberNumber')); } $fields->addFieldToTab('Root.MembershipDetails', TextField::create('HomePhone')); $fields->addFieldToTab('Root.MembershipDetails', TextField::create('WorkPhone')); $fields->addFieldToTab('Root.MembershipDetails', TextField::create('MobilePhone')); $fields->addFieldToTab('Root.MembershipDetails', TextareaField::create('Address')); $fields->addFieldToTab('Root.MembershipDetails', TextField::create('Occupation')); $fields->addFieldToTab('Root.MembershipDetails', TextField::create('BirthDate')); $expiry->setConfig('showcalendar', true); $expiry->setConfig('showdropdown', true); $expiry->setConfig('dateformat', 'dd-MM-YYYY'); $discountExpiry->setConfig('showcalendar', true); $discountExpiry->setConfig('showdropdown', true); $discountExpiry->setConfig('dateformat', 'dd-MM-YYYY'); $joined->setConfig('showcalendar', true); $joined->setConfig('showdropdown', true); $joined->setConfig('dateformat', 'dd-MM-YYYY'); }
/** * getCMSFields * Construct the FieldList used in the CMS. To provide a * smarter UI we don't use the scaffolding provided by * parent::getCMSFields. * * @return FieldList */ public function getCMSFields() { Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css'); //Create the FieldList and push the Root TabSet on to it. $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Currency"), CompositeField::create(DropdownField::create("Enabled", "Enable Currency?", array("1" => "Yes", "2" => "No"))->setRightTitle($this->SystemCreated == 1 ? "DISABLED: You can not disable the default currency." : "Select the country this zone applies to.")->setDisabled($this->SystemCreated == 1 ? true : false), TextField::create("Title", "Currency Name")->setRightTitle("i.e. Great British Pound."), TextField::create("Code", "Currency Code")->setRightTitle("i.e. GBP, USD, EUR."), TextField::create("ExchangeRate", "Exchange Rate")->setRightTitle("i.e. Your new currency is USD, a conversion rate of 1.53 may apply against the local currency."), TextField::create("Symbol", "Currency Symbol")->setRightTitle("i.e. £, \$, €."), DropdownField::create("SymbolLocation", "Symbol Location", array("1" => "On the left, i.e. \$1.00", "2" => "On the right, i.e. 1.00\$", "3" => "Display the currency code instead, i.e. 1 USD."))->setRightTitle("Where should the currency symbol be placed?"), TextField::create("DecimalSeperator", "Decimal Separator")->setRightTitle("What decimal separator does this currency use?"), TextField::create("ThousandsSeparator", "Thousands Separator")->setRightTitle("What thousands separator does this currency use?"), NumericField::create("DecimalPlaces", "Decimal Places")->setRightTitle("How many decimal places does this currency use?"))))); return $fields; }
public function __construct($controller, $name) { $product = new Product(); $title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title')); $urlSegment = new TextField('URLSegment', 'URL Segment'); $menuTitle = new TextField('MenuTitle', 'Navigation Title'); $sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30); $categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category.")); $otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true); $model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30); $featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product')); $allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content'); $price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12); $image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image')); $content = new HtmlEditorField('Content', 'Content'); $fields = new FieldList(); $fields->add($title); //$fields->add($urlSegment); //$fields->add($menuTitle); //$fields->add($sku); $fields->add($categories); //$fields->add($otherCategories); $fields->add($model); $fields->add($featured); $fields->add($allow_purchase); $fields->add($price); $fields->add($image); $fields->add($content); //$fields = $product->getFrontEndFields(); $actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product'))); $requiredFields = new RequiredFields(array('Title', 'Model', 'Price')); parent::__construct($controller, $name, $fields, $actions, $requiredFields); }
public function getCMSFields() { $fields = parent::getCMSFields(); // Main Content tab // Carousel tab $carouselItemsGrid = null; // Manay to many relations can only be established if we have an id. So put a place holder instead of a grid if this is a new object. if ($this->ID == 0) { $carouselItemsGrid = TextField::create("CarouselItems", "Carousel Items")->setDisabled(true)->setValue("Page must be saved once before adding Carousel Items."); } else { $carouselItemsGrid = new GridField('CarouselItems', 'Carousel', $this->CarouselItems()->sort('Archived'), GridFieldConfig_RelationEditor::create()); $carouselItemsGridUploadComponent = new GridFieldBulkUpload("Image"); $carouselItemsGridUploadComponent->setUfSetup("setFolderName", $this->ImageFolder("carousel")); $carouselItemsGrid->setModelClass('CarouselItem')->getConfig()->addComponent($carouselItemsGridUploadComponent)->addComponent(new GridFieldOrderableRows("SortID")); } $fields->addFieldToTab('Root.Carousel', $carouselItemsGrid); // Links $fields->addFieldToTab('Root.Links', new TreeDropdownField('LearnMorePageID', 'Page to link the "Learn More" button to:', 'SiteTree')); $fields->addFieldToTab('Root.Links', new TextField('LearnMoreButtonText', 'Text to display on the "Learn More" button:', 'SiteTree')); $quickLinksGrid = new GridField('Quicklinks', 'Quicklinks', $this->Quicklinks(), GridFieldConfig_RelationEditor::create()); $quickLinksGrid->setModelClass('Quicklink'); $quickLinksFieldGroup = FieldGroup::create($quickLinksGrid)->setTitle('Quick Links'); $quickLinksFieldGroup->setName("QuicklinkGroup"); $fields->addFieldToTab('Root.Links', $quickLinksFieldGroup); $fields->removeByName('Translations'); $fields->removeByName('Import'); $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'), array(new TextField('FeatureOneTitle', 'Title'), new DropdownField('FeatureOneCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureOneCategory')->enumValues()), new HTMLEditorField('FeatureOneContent', 'Content'), new TreeDropdownField('FeatureOneLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureOneButtonText', 'Button text')))->setHeadingLevel(3)); $fields->addFieldToTab('Root.Features', ToggleCompositeField::create('FeatureTwo', _t('SiteTree.FeatureTwo', 'Feature Two'), array(new TextField('FeatureTwoTitle', 'Title'), new DropdownField('FeatureTwoCategory', 'Category', singleton('ExpressHomePage')->dbObject('FeatureTwoCategory')->enumValues()), new HTMLEditorField('FeatureTwoContent', 'Content'), new TreeDropdownField('FeatureTwoLinkID', 'Page to link to', 'SiteTree'), new TextField('FeatureTwoButtonText', 'Button text')))->setHeadingLevel(3)); 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.'))); } }
/** * A simple form for creating blog entries */ function FrontEndPostForm() { if ($this->owner->request->latestParam('ID')) { $id = (int) $this->owner->request->latestParam('ID'); } else { $id = 0; } $membername = Member::currentUser() ? Member::currentUser()->getName() : ""; // Set image upload $uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image")); $uploadfield->setCanAttachExisting(false); $uploadfield->setCanPreviewFolder(false); $uploadfield->setAllowedFileCategories('image'); $uploadfield->relationAutoSetting = false; if (BlogFrontEnd::config()->allow_wysiwyg_editing) { $content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content")); } else { $content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content")); } $form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title')); $uploadfield->setForm($form); if ($this->owner->Categories()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map())); } if ($this->owner->Tags()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map())); } if ($id && ($post = BlogPost::get()->byID($id))) { $form->loadDataFrom($post); } $this->owner->extend("updateFrontEndPostForm", $form); return $form; }
/** * Display the vanity mapping fields. */ public function updateSettingsFields($fields) { $fields->addFieldToTab('Root.Misdirection', HeaderField::create('VanityHeader', 'Vanity')); $fields->addFieldToTab('Root.Misdirection', TextField::create('VanityURL', 'URL', $this->owner->VanityMapping()->MappedLink)->setRightTitle('Mappings with higher priority will take precedence over this')); // Allow extension customisation. $this->owner->extend('updateSiteTreeMisdirectionExtensionSettingsFields', $fields); }
public function getCMSFields() { $fields = parent::getCMSFields(); // Remove fields $fields->removeByName(array('Unique', 'Permanent', 'CanClose', 'CloseColor', 'LinkID')); // Add fields // Main tab $fields->addFieldToTab("Root.Main", $test = TextField::create("ButtonText")->setTitle(_t("SiteMessage.LABELBUTTONTEXT", "Button Text"))); $fields->addFieldToTab("Root.Main", TreeDropdownField::create("PageID")->setTitle(_t("SiteMessage.LABELLINKTO", "Link to"))->setSourceObject("SiteTree")); $fields->addFieldToTab("Root.Main", HTMLEditorField::create("Content")->setTitle(_t("SiteMessage.LABELCONTENT", "Message content"))->setRows(15)); // Design tab $fields->addFieldToTab("Root.Design", HeaderField::create("ColorSettings")->setTitle(_t("SiteMessage.HEADERCOLORSETTINGS", "Color settings"))); $fields->addFieldToTab("Root.Design", ColorField::create("BackgroundColor")->setTitle(_t("SiteMessage.LABELBACKGROUNDCOLOR", "Background Color"))); $fields->addFieldToTab("Root.Design", ColorField::create("TextColor")->setTitle(_t("SiteMessage.LABELTEXTCOLOR", "Text Color"))); $fields->addFieldToTab("Root.Design", ColorField::create("ButtonColor")->setTitle(_t("SiteMessage.LABELBUTTONCOLOR", "Button Color"))); $fields->addFieldToTab("Root.Design", ColorField::create("ButtonTextColor")->setTitle(_t("SiteMessage.LABELBUTTONTEXTCOLOR", "Button Text Color"))); $fields->addFieldToTab("Root.Design", HeaderField::create("CloseSettings")->setTitle(_t("SiteMessage.HEADERCLOSESETTINGS", "Close button settings"))); $fields->addFieldToTab("Root.Design", FieldGroup::create(_t("SiteMessage.LABELCANCLOSE", "Show close button?"), Checkboxfield::create("CanClose", ""))); $fields->addFieldToTab("Root.Design", ColorField::create("CloseColor")->setTitle(_t("SiteMessage.LABELCLOSECOLOR", "Close button color"))); // Schedule tab $fields->addFieldToTab("Root.Schedule", FieldGroup::create(_t("SiteMessage.LABELPERMANENT", "Is this message permanent?"), CheckboxField::create("Permanent", ""))); $fields->addFieldToTab("Root.Schedule", $Start = new DatetimeField("Start")); $fields->addFieldToTab("Root.Schedule", $End = new DatetimeField("End")); $Start->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "Start Date"))->getDateField('Start')->setConfig('showcalendar', TRUE); $End->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "End Date"))->getDateField('End')->setConfig('showcalendar', TRUE); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab("Root.SuccessContent", array(TextField::create("Currency"), TextField::create("SuccessTitle"), HTMLEditorField::create("SuccessContent"))); $fields->addFieldToTab("Root.Invoices", GridField::create("Invoices", "Invoices", $this->Invoices(), GridFieldConfig_RecordEditor::create())); return $fields; }
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; }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList($Email = EmailField::create('Email')->setTitle(_t('ContactForm.EMAIL', 'ContactForm.EMAIL')), $Name = TextField::create('Name')->setTitle(_t('ContactForm.NAME', 'ContactForm.NAME')), $Message = TextareaField::create('Message')->setTitle(_t('ContactForm.MESSAGE', 'ContactForm.MESSAGE'))); $actions = new FieldList($Submit = FormAction::create('doContact')->setTitle(_t('ContactForm.BUTTONSEND', 'ContactForm.BUTTONSEND'))); $Submit->addExtraClass('btn'); parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Email", "Name", "Message")); }
/** * Method that turns this object into a field type, to be loaded into a form * * @return FormField */ public function Field() { if ($this->Title && $this->DisplayAs) { $name = "customise_{$this->ID}_" . Convert::raw2url($this->Title); $title = $this->Required ? $this->Title . ' *' : $this->Title; $options = $this->Options()->map('Title', 'ItemSummary'); $defaults = $this->DefaultOptions(); $default = $defaults->exists() ? $defaults->first()->Title : null; switch ($this->DisplayAs) { case 'Dropdown': $field = DropdownField::create($name, $title, $options, $default)->setEmptyString(_t('Commerce.PleaseSelect', 'Please Select'))->setAttribute("class", "dropdown btn"); break; case 'Radio': $field = OptionSetField::create($name, $title, $options, $default); break; case 'Checkboxes': $field = CheckboxSetField::create($name, $title, $options, $defaults->column('ID')); break; case 'TextEntry': $field = TextField::create($name, $title); if ($this->MaxLength) { $field->setMaxLength($this->MaxLength); } break; } $this->extend('updateField', $field); return $field; } else { return false; } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Profiles', GridField::create('Profiles', 'Profiles on this page', $this->Profiles(), GridFieldConfig_RecordEditor::create())); $fields->addFieldToTab('Root.Main', TextField::create('Subheading', 'Page Subheading'), 'Content'); return $fields; }
public function getCMSFields() { $fields = FieldList::create(HeaderField::create('Outer Captions'), $category = DropdownField::create('FeaturedWorkCategoryID', 'Category', ProjectCategory::get()->map('ID', 'Title')), $imgUploadField = UploadField::create('ProjectCoverImage', 'Cover Image'), TextareaField::create('ProjectBriefDesc', 'Hover Over Description'), TextField::create('ProjectTitle', 'Title'), HeaderField::create('Project Phases'), $imgPhase1 = UploadField::create('ProjectPhaseImg1', 'Phase 1 Image'), TextareaField::create('ProjectPhaseDesc1', 'Phase 1 Description'), $imgPhase2 = UploadField::create('ProjectPhaseImg2', 'Phase 2 Image'), TextareaField::create('ProjectPhaseDesc2', 'Phase 2 Description'), $imgPhase3 = UploadField::create('ProjectPhaseImg3', 'Phase 3 Image'), TextareaField::create('ProjectPhaseDesc3', 'Phase 3 Description'), $imgPhase4 = UploadField::create('ProjectPhaseImg4', 'Phase 4 Image'), TextareaField::create('ProjectPhaseDesc4', 'Phase 4 Description'), $imgPhase5 = UploadField::create('ProjectPhaseImg5', 'Phase 5 Image'), TextareaField::create('ProjectPhaseDesc5', 'Phase 5 Description'), $imgPhase6 = UploadField::create('ProjectPhaseImg6', 'Phase 6 Image'), TextareaField::create('ProjectPhaseDesc6', 'Phase 6 Description')); //create inner GridField for ProjectPhases images /*$fields->addFieldToTab('Root.Phases', GridField::create( 'ProjectPhases', 'Project Phases', $this->ProjectPhases(), GridFieldConfig_RecordEditor::create() ));*/ //set image upload getTempFolder $imgUploadField->setFolderName('Featured Works Images'); //validate image upload types $imgUploadField->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 1 $imgPhase1->setFolderName('Project Phase Images'); $imgPhase1->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 2 $imgPhase2->setFolderName('Project Phase Images'); $imgPhase2->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 3 $imgPhase3->setFolderName('Project Phase Images'); $imgPhase3->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 4 $imgPhase4->setFolderName('Project Phase Images'); $imgPhase4->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 5 $imgPhase5->setFolderName('Project Phase Images'); $imgPhase5->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //project phase img 6 $imgPhase6->setFolderName('Project Phase Images'); $imgPhase6->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); //return the fields return $fields; }
/** * Returns a FieldList with which to create the main editing form. * * @return FieldList The fields to be displayed in the CMS. */ public function getCMSFields() { // Get the CMS fields $fields = parent::getCMSFields(); // Update the existing fields with labels $nameField = $fields->dataFieldByName("Title"); if ($nameField) { $nameField->setRightTitle("Staff members name (John Smith etc)"); } // Add the fields to the CMS $fields->addFieldToTab("Root.Main", TextField::create("Position", _t("StaffProfilePage.PositionTitle", "Position")), "Content"); $fields->addFieldToTab("Root.Main", EmailField::create("Email", _t("StaffProfilePage.EmailTitle", "Email address")), "Content"); $fields->addFieldToTab("Root.Main", TextField::create("Phone", _t("StaffProfilePage.PhoneTitle", "Phone")), "Content"); $fields->addFieldToTab("Root.Categories", GridField::create("Categories", _t("StaffProfilePage.CategoriesTitle", "Categories"), $this->Categories(), StaffProfilePage_Category::getGridFieldConfig())); // Add the thumbnail field $uploadField = UploadField::create("Thumbnail", _t("StaffProfilePage.ThumbnailTitle", "Thumbnail")); $uploadField->setFolderName('Staff'); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); $sizeMB = 0.3; // MB $size = $sizeMB * 1024 * 1024; // Bytes $uploadField->getValidator()->setAllowedMaxFileSize($size); $fields->addFieldToTab("Root.Main", $uploadField, "Content"); $this->extend('updateCMSFields', $fields); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ConfiguredScheduleID'); $interval = $fields->dataFieldByName('Interval')->setDescription('Number of seconds between each run. e.g 3600 is 1 hour'); $fields->replaceField('Interval', $interval); $dt = new DateTime(); $fields->replaceField('StartDate', DateField::create('StartDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y'))); $fields->replaceField('EndDate', DateField::create('EndDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y'))); if ($this->ID == null) { foreach ($fields->dataFields() as $field) { //delete all included fields $fields->removeByName($field->Name); } $rangeTypes = ClassInfo::subclassesFor('ScheduleRange'); $fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title')); $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Range Type', $rangeTypes)); } else { $fields->addFieldToTab('Root.Main', ReadonlyField::create('ClassName', 'Type')); } if ($this->ClassName == __CLASS__) { $fields->removeByName('ApplicableDays'); } return $fields; }
/** * CMS Fields * @return array */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab("Root.Main", array(UploadField::create('Image')->setFolderName('Person'), TextField::create('Name'), TextField::create('Title'), TextField::create('Email'), TextField::create('Phone'), TextField::create('Mobile'), HTMLEditorField::create('Description'))); $this->extend('updateCMSFields', $fields); return $fields; }
private function Form() { $fields = FieldList::create(TextField::create('Title'), TextField::create('Subtitle')); $actions = FieldList::create(FormAction::create('submit', 'submit')); $validator = ZenValidator::create(); return Form::create(Controller::curr(), 'Form', $fields, $actions, $validator); }
function getCMSFields() { $fields = FieldList::create(TabSet::create(Root)); $fields->addFieldToTab("Root.Main", TextField::create('Name', 'Series Name')); // $fields->addFieldToTab("Root.Main", UploadField::create('Icon', 'Series Icon')); return $fields; }
public function getCMSFields() { $fields = FieldList::create(TextField::create('Title'), TextareaField::create('CaptionText'), $uploader = UploadField::create('Photo')); $uploader->setFolderName('home-slides'); $uploader->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpeg', 'jpg')); return $fields; }
public function getCMSFields() { $fields = FieldList::create(TextField::create('Title'), HtmlEditorField::create('Description'), $uploader = UploadField::create('Photo')); $uploader->setFolderName('region-photos'); $uploader->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpeg', 'jpg')); return $fields; }
public function updateCMSFields(FieldList $fields) { $fields->remove("PhoneNumber"); $fields->addFieldToTab("Root.Main", TextField::create("PhoneNumber"), "Password"); $fields->addFieldToTab("Root.Main", TextField::create("Company"), "FirstName"); return $fields; }
public function updateFields($fields) { Requirements::javascript(MISDIRECTION_PATH . '/javascript/misdirection-fallback.js'); // Update any fields that are displayed when not viewing a page. $tab = 'Root.Misdirection'; $options = array('Nearest' => 'Nearest Parent', 'This' => 'This Page', 'URL' => 'URL'); if ($this->owner instanceof SiteConfig) { $tab = 'Root.Pages'; unset($options['This']); } // Retrieve the fallback mapping selection. $fields->addFieldToTab($tab, HeaderField::create('FallbackHeader', 'Fallback')); $fields->addFieldToTab($tab, DropdownField::create('Fallback', 'To', $options)->addExtraClass('fallback')->setHasEmptyDefault(true)->setRightTitle('This will be used when children result in a <strong>page not found</strong>')); $fields->addFieldToTab($tab, TextField::create('FallbackLink', 'URL')->addExtraClass('fallback-link')); // Retrieve the response code selection. $responses = Config::inst()->get('SS_HTTPResponse', 'status_codes'); $selection = array(); foreach ($responses as $code => $description) { if ($code >= 300 && $code < 400) { $selection[$code] = "{$code}: {$description}"; } } $fields->addFieldToTab($tab, DropdownField::create('FallbackResponseCode', 'Response Code', $selection)->addExtraClass('fallback-response-code')); // Allow extension customisation. $this->owner->extend('updateMisdirectionFallbackExtensionFields', $fields); }
/** * @param Controller $controller * @param String $name * @param array $arguments */ public function __construct($controller, $name, $arguments = array()) { /** ========================================= * @var EmailField $emailField * @var TextField $nameField * @var FormAction $submit * @var Form $form ===========================================*/ /** ----------------------------------------- * Fields * ----------------------------------------*/ $emailField = EmailField::create('Email', 'Email Address'); $emailField->addExtraClass('form-control')->setAttribute('placeholder', 'Email')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>'); $nameField = TextField::create('Name', 'Name'); $nameField->setAttribute('placeholder', 'Name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Name</strong>')->setCustomValidationMessage('Please enter your <strong>Name</strong>'); $fields = FieldList::create($nameField, $emailField); /** ----------------------------------------- * Actions * ----------------------------------------*/ $submit = FormAction::create('Subscribe'); $submit->setTitle('SIGN UP')->addExtraClass('button'); $actions = FieldList::create($submit); /** ----------------------------------------- * Validation * ----------------------------------------*/ $required = RequiredFields::create('Name', 'Email'); $form = Form::create($this, $name, $fields, $actions, $required); if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) { $form->loadDataFrom($formData); } parent::__construct($controller, $name, $fields, $actions, $required); $this->setAttribute('data-parsley-validate', true); $this->addExtraClass('form'); }
public function getCMSFields() { $fields = new FieldList(); $fields->push(TextField::create("TwitterHandle", "Twitter Handle")); $fields->push(NumericField::create("NumberOfTweets", "Number of Tweets")); return $fields; }
public function updateCMSFields(\FieldList $fields) { if (!$this->owner->exists()) { return; } $fields->addFieldsToTab('Root.Recommended', [\TextField::create('Recommended_Title', _t('Product.Recommended_Title', 'Title'))->setAttribute('placeholder', $this->owner->config()->recommended_title ?: _t('Product.Default-Recommended_Title', 'Recommended Products')), \CheckboxField::create('Recommended_AlsoBought', _t('Product.Recommended_AlsoBought', 'Prioritise products that were bought with this product?'))->setDescription(_t('Product.Desc-Recommended_AlsoBought', 'This will use products that previous customers have bought with this product, otherwise it will select from your choice below.')), \SelectionGroup::create('Recommended_FindBy', $this->getMethodFormFields())]); }
/** * Return the payment form */ public function PayForm() { $request = $this->getRequest(); $response = Session::get('EwayResponse'); $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'); $years = range(date('y'), date('y') + 10); //Note: years beginning with 0 might cause issues $amount = $response->Payment->TotalAmount; $amount = number_format($amount / 100, 2); $currency = $response->Payment->CurrencyCode; $fields = new FieldList(HiddenField::create('EWAY_ACCESSCODE', '', $response->AccessCode), TextField::create('PayAmount', 'Amount', $amount . ' ' . $currency)->setDisabled(true), $nameField = TextField::create('EWAY_CARDNAME', 'Card holder'), $numberField = TextField::create('EWAY_CARDNUMBER', 'Card Number'), $expMonthField = DropdownField::create('EWAY_CARDEXPIRYMONTH', 'Expiry Month', array_combine($months, $months)), $expYearField = DropdownField::create('EWAY_CARDEXPIRYYEAR', 'Expiry Year', array_combine($years, $years)), $cvnField = TextField::create('EWAY_CARDCVN', 'CVN Number'), HiddenField::create('FormActionURL', '', $response->FormActionURL)); //Test data if (Director::isDev()) { $nameField->setValue('Test User'); $numberField->setValue('4444333322221111'); $expMonthField->setValue('12'); $expYearField->setValue(date('y') + 1); $cvnField->setValue('123'); } $actions = new FieldList(FormAction::create('', 'Process')); $form = new Form($this, 'PayForm', $fields, $actions); $form->setFormAction($response->FormActionURL); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('payment-eway/javascript/eway-form.js'); $this->extend('updatePayForm', $form); return $form; }