public function updateCMSFields(FieldList $fields) { $fields->insertBefore($shoptab = new Tab('Shop', 'Shop'), 'Access'); $fields->addFieldsToTab("Root.Shop", new TabSet("ShopTabs", $maintab = new Tab("Main", TreeDropdownField::create('TermsPageID', _t("ShopConfig.TERMSPAGE", 'Terms and Conditions Page'), 'SiteTree'), TreeDropdownField::create("CustomerGroupID", _t("ShopConfig.CUSTOMERGROUP", "Group to add new customers to"), "Group"), UploadField::create('DefaultProductImage', _t('ShopConfig.DEFAULTIMAGE', 'Default Product Image'))), $countriestab = new Tab("Countries", CheckboxSetField::create('AllowedCountries', 'Allowed Ordering and Shipping Countries', self::config()->iso_3166_country_codes)))); $fields->removeByName("CreateTopLevelGroups"); $countriestab->setTitle("Allowed Countries"); }
/** * 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; } }
function TypoForm() { $array = array('green', 'yellow', 'blue', 'pink', 'orange'); $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField')); $textAreaField->setColumns(45); $form->setMessage('warning message', 'warning'); return $form; }
public function getCMSFields() { $fields = parent::getCMSFields(); $cmsUsers = Member::mapInCMSGroups(); $fields->addFieldsToTab('Root.Main', array(new HeaderField('AssignUsers', $this->fieldLabel('AssignUsers')), new CheckboxField('AssignInitiator', $this->fieldLabel('AssignInitiator')), $users = CheckboxSetField::create('Users', $this->fieldLabel('Users'), $cmsUsers), new TreeMultiselectField('Groups', $this->fieldLabel('Groups'), 'Group'))); // limit to the users which actually can access the CMS $users->setSource(Member::mapInCMSGroups()); return $fields; }
public function __construct($modelClass, $newsAdmin = null, $fields = null, $filters = null) { $fields = new FieldList(TextField::create('Title'), TextField::create('URLSegment'), DropdownField::create('ParentID', 'Parent page')->setSource(NewsIndex::get()->map('ID', 'Title')->toArray())->setEmptyString('Select'), HeaderField::create('DatesHeader', 'Dates')->setHeadingLevel(3), DateField::create('StartDate')->setTitle(null)->setAttribute('placeholder', 'Start Date'), DateField::create('EndDate')->setTitle(null)->setAttribute('placeholder', 'End Date'), CheckboxSetField::create('Types')->setSource(NewsSearchContext::GetNewsTypes($newsAdmin))->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Types']) ? $_REQUEST['q']['Types'] : null), TextField::create('Tags'), TextField::create('Summary'), TextField::create('Content'), TextField::create('Author'), CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray())->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Categories']) ? $_REQUEST['q']['Categories'] : null)); $filters = array('Title' => new PartialMatchFilter('Title'), 'URLSegment' => new PartialMatchFilter('URLSegment'), 'ParentID' => new ExactMatchFilter('ParentID'), 'Tags' => new PartialMatchFilter('Tags'), 'Summary' => new PartialMatchFilter('Summary'), 'Content' => new PartialMatchFilter('Content'), 'Author' => new PartialMatchFilter('Author'), 'StartDate' => new GreaterThanOrEqualFilter('DateTime'), 'EndDate' => new LessThanOrEqualFilter('DateTime')); if ($newsAdmin) { $this->newsAdmin = $newsAdmin; } parent::__construct($modelClass, $fields, $filters); }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList(ReadonlyField::create('Title')->setTitle(_t('Box.TITLE', 'Box.TITLE')), TextareaField::create('Description')->setTitle(_t('Box.DESCRIPTION', 'Box.DESCRIPTION')), CheckboxField::create("Public")->setTitle(_t('Box.PUBLIC', 'Box.PUBLIC')), $Members = CheckboxSetField::create('Members')->setTitle(_t('Box.MEMBERS', 'Box.MEMBERS'))->setSource(Member::get()->map('ID', 'Name')), HiddenField::create('BoxID')); $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doEdit')->setTitle(_t('BoxEditForm.DOEDIT', 'BoxEditForm.DOEDIT'))); parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Description")); if (isset($GLOBALS['BoxID'])) { $Box = Box::get()->byID($GLOBALS['BoxID']); $this->loadDataFrom($Box); } }
/** * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { if (Config::inst()->get('FacetedCategory', 'show_disabled_facets_tab')) { $spec = FacetHelper::inst()->expandFacetSpec($this->getFacetSpec()); $facets = array(); foreach ($spec as $f => $v) { $facets[$f] = $v['Label']; } $fields->addFieldToTab('Root.Facets', CheckboxSetField::create('DisabledFacets', "Don't show the following facets for this category:", $facets)); } }
/** * Adds variations specific fields to the CMS. */ public function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.Attributes', array(HeaderField::create('Applicable Attribute Types'), CheckboxSetField::create('StaticAttributeTypes', 'Static Attribute Types', ProductAttributeType::get()->map("ID", "Title")), LiteralField::create('staticattributehelp', '<p>Select any attributes that apply to this product and click Save.</p>'), HeaderField::create('Attributes'))); foreach ($this->owner->StaticAttributeTypes() as $type) { $source = $this->getValuesClosure($type->ID); $newValFields = FieldList::create(array(TextField::create('Value', 'Label'), HiddenField::create('TypeID', '', $type->ID))); $newValReq = RequiredFields::create('Value'); $valuesField = HasStaticAttributes_CheckboxSetField::create('StaticAttributeValues-' . $type->ID, $type->Title, $source()); $valuesField->setValue($this->owner->StaticAttributeValues()->filter('TypeID', $type->ID)->getIDList()); $valuesField->useAddNew('ProductAttributeValue', $source, $newValFields, $newValReq); $fields->addFieldToTab('Root.Attributes', $valuesField); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Attachments', $photo = UploadField::create('Photo')); $fields->addFieldToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)')); $photo->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); $photo->setFolderName('travel-photos'); $brochure->getValidator()->setAllowedExtensions(array('pdf')); $brochure->setFolderName('travel-brochures'); $fields->addFieldToTab('Root.Categories', CheckboxSetField::create('Categories', 'Selected categories', $this->Parent()->Categories()->map('ID', 'Title'))); $fields->addFieldToTab('Root.Main', DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title'))->setEmptyString('-- None --'), 'Content'); return $fields; }
/** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Orders'); $fields->replaceField('Statuses', CheckboxSetField::create('Statuses', 'Statuses', Order::get_order_status_options())); $fields->replaceField('Active', DropdownField::create('Active', 'Active', array(0 => 'No', 1 => 'Yes'))); $instructions = ''; foreach ($this->getSubstitutions() as $k => $v) { $instructions .= '<li><strong>{{{' . $k . '}}}</strong>: ' . $v . '</li>'; } $fields->addFieldToTab('Root.Main', LiteralField::create('contentinstructions', "<p>The following will be replaced anywhere they appear in the content of the email:</p>" . "<ul>{$instructions}</ul>"), 'HtmlContent'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); // TODO: Change the autogenerated stub $fields->addFieldsToTab('Root.Main', DateField::create('Date', 'article date'), 'Content'); $fields->addFieldsToTab('Root.Main', TextareaField::create('Teaser', 'Teaser text'), 'Content'); $fields->addFieldsToTab('Root.Main', TextField::create('Author', 'Who made this post possible'), 'Content'); $fields->addFieldToTab('Root.Attachments', $photo = UploadField::create('Photo')); $fields->addFieldToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)')); $photo->setFolderName('travel-photos'); $brochure->setFolderName('travel-brochures')->getValidator()->setAllowedExtensions(array('pdf')); $fields->addFieldsToTab('Root.Categories', CheckboxSetField::create('Categories', 'Categories this article belongs to', $this->Parent()->Categories()->map('ID', 'Title'))); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', DateField::create('Date', 'Date of article')->setConfig('showcalendar', true), 'Content'); $fields->addFieldsToTab('Root.Main', TextareaField::create('Teaser'), 'Content'); $fields->addFieldsToTab('Root.Main', TextField::create('Author', 'Author of article'), 'Content'); $fields->addFieldsToTab('Root.Attachments', $photo = UploadField::create('Photo')); $fields->addFieldsToTab('Root.Attachments', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)')); $photo->setFolderName('travel-photos'); $brochure->setFolderName('travel-brochures')->getValidator()->setAllowedExtensions(array('pdf')); $fields->addFieldsToTab('Root.Categories', CheckboxSetField::create('Categories', 'Selected categories', $this->Parent()->Categories()->map('ID', 'Title'))); $fields->addFieldsToTab('Root.Main', DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title'))->setEmptyString('-- None --'), 'Content'); return $fields; }
function getSearchFields() { if ($this->fields && $this->fields->count()) { return $this->fields; } $fields = new FieldList(TextField::create('Name'), TextField::create('Email'), TextField::create('Company'), CheckboxSetField::create('Status')->setSource(CustomerStatus::get()->map()->toArray()), CheckboxSetField::create('Tags')->setSource(CustomerTag::get()->map()->toArray())); $locales = PostmarkHelper::MemberLocales(); if ($locales && count($locales)) { $locale = DropdownField::create('Locale')->setSource($locales)->setEmptyString('Select language'); $fields->insertBefore($locale, 'Name'); } $this->extend('updateCustomerSearchFields', $fields); $this->fields = $fields; return $this->fields; }
public function __construct($controller, $name, $poll) { if (!$poll) { user_error("The poll doesn't exist.", E_USER_ERROR); } $this->poll = $poll; $data = $poll->Answers()->map('ID', 'Title'); if ($poll->Multiple) { $choiceField = CheckboxSetField::create('PollChoices', $poll->Question, $data); } else { $choiceField = OptionsetField::create('PollChoices', '', $data); } $fields = FieldList::create($choiceField); $actions = FieldList::create(FormAction::create('submitPoll', 'Verstuur')); $validator = RequiredFields::create(array('PollChoices')); parent::__construct($controller, $name, $fields, $actions, $validator); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Members'); $fields->removeByName('AccountID'); $fields->dataFieldByName('establish_time')->setConfig('showcalendar', true); $fields->dataFieldByName('register_time')->setConfig('showcalendar', true); $fields->replaceField('company_name', new ReadonlyField('company_name', '企业名称')); $fields->replaceField('company_class', CheckboxSetField::create('company_class', '企业类别', array('高新技术企业 - 国家' => '高新技术企业 - 国家', '高新技术企业 - 市' => '高新技术企业 - 市', '省级创新型示范企业' => '省级创新型示范企业', '省级创新型试点企业' => '省级创新型试点企业', '省级科技型中小企业' => '省级科技型中小企业', '省级专利示范企业' => '省级专利示范企业', '省级农业科技型企业' => '省级农业科技型企业', '市级专利示范企业' => '市级专利示范企业', '市级创新型企业' => '市级创新型企业', '县级科技型企业' => '县级科技型企业', '其他' => '其他'))); $fields->replaceField('research_class', CheckboxSetField::create('research_class', '研发中心类别', array('省级企业研究院' => '省级企业研究院', '省级高新技术企业研发中心' => '省级高新技术企业研发中心', '省级农业企业科技研发中心' => '省级农业企业科技研发中心', '省级区域科技创新服务中心' => '省级区域科技创新服务中心', '省级大院名校共建创新载体' => '省级大院名校共建创新载体', '市级工程技术研究开发中心' => '市级工程技术研究开发中心', '企业所属研发机构' => '企业所属研发机构', '其他' => '其他'))); $fields->replaceField('research_construction', CheckboxSetField::create('research_construction', '研发中心建设', array('国家级' => '国家级', '省级' => '省级', '市级' => '市级', '县级' => '县级'))); $fields->replaceField('tech_upgrade', CheckboxSetField::create('tech_upgrade', '科技型企业升级', array('国家级' => '国家级', '省级' => '省级', '市级' => '市级', '县级' => '县级'))); $fields->addFieldToTab('Root.Main', LiteralField::create('企业规模和占地情况', '<h3>企业规模和占地情况</h3>'), 'floor_space'); $fields->addFieldToTab('Root.Main', LiteralField::create('科研活动情况', '<h3>科研活动情况</h3>'), 'tech_member'); $fields->addFieldToTab('Root.Main', LiteralField::create('科技创新项目意向', '<h3>科技创新项目意向</h3>'), 'patent_invent'); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', DateField::create('Date', 'Date of article')->setConfig('showcalendar', true)->setConfig('dateformat', 'd MMMM yyyy'), 'Content'); $fields->addFieldToTab('Root.Main', TextareaField::create('Teaser'), 'Content'); $fields->addFieldToTab('Root.Main', TextField::create('Author', 'Author of article')->setDescription('If multiple authors, separated with commas')->setMaxLength(50), 'Content'); $fields->addFieldToTab('Root.Attachment', $photo = UploadField::create('Photo')); $fields->addFieldToTab('Root.Attachment', $brochure = UploadField::create('Brochure', 'Travel brochure, optional (PDF only)')); $photo->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg')); $photo->setFolderName('travel-photos'); $brochure->getValidator()->setAllowedExtensions(array('pdf')); $brochure->setFolderName('travel-brochures'); //1st param on the checksetfield is Categories the name of the many many relationship //2nd param is the label of the checkbox //3rd param is the source of the checkbox //map tell the checkbox to save the ID to the relationship but present the title field as the label of the checkbox //99% of the time the ID is the first argument $fields->addFieldToTab('Root.Categories', CheckboxSetField::create('Categories', 'Select categories', $this->Parent()->Categories()->map('ID', 'Title'))); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); if (!Config::inst()->get('NewsPost', 'pages_admin')) { $arrTypes = NewsPost::GetNewsTypes(); if (count($arrTypes) > 1) { $arrDropDownSource = array(); foreach ($arrTypes as $strType) { $arrDropDownSource[$strType] = $strType; } $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName')->setSource($arrDropDownSource)->setTitle('Type'), 'Content'); } } $fields->addFieldsToTab('Root.Main', array(DropdownField::create('ParentID')->setSource(NewsIndex::get()->map()->toArray())->setTitle('Parent Page'), DatetimeField::create('DateTime'), TextField::create('Tags'), TextField::create('Author'), HtmlEditorField::create('Summary')->setRows(5)), 'Content'); if ($this->ID) { $fields->addFieldToTab('Root.Main', CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray()), 'Content'); $fields->addFieldToTab('Root.RelatedArticles', GridField::create('RelatedArticles', 'Related Articles')->setList($this->RelatedArticles())->setConfig($relatedArticlesConfig = new GridFieldConfig_RelationEditor())); } $this->extend('updateNewsPostCMSFields', $fields); return $fields; }
public function SS_ConstantContactForm() { Requirements::css(CONSTANT_CONTACT_BASE . '/css/cc_ccs.css'); Requirements::javascript(CONSTANT_CONTACT_BASE . '/js/cc_js.js'); $config = $this->owner; $listIDs = $config->CcListID->getValues(); if (is_array($listIDs)) { if (count($listIDs) == 1) { $listfield = HiddenField::create('list')->setValue(reset($listIDs)); } else { $lists = $this->owner->CcListCache; if (!$lists) { $lists = singleton('SS_ConstantContactController')->getLists(true, $listIDs); if ($lists) { $this->owner->CcListCache = serialize($lists); $this->owner->write(); } } else { $lists = unserialize($lists); } $listfield = CheckboxSetField::create('list', 'List Options', $lists)->addExtraClass('form-control ' . $config->CcInputFieldClasses); } } else { return false; } $fields = new FieldList(array(TextField::create('email')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Email'), TextField::create('first_name')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'First Name'), TextField::create('last_name')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Last Name'), $listfield, LiteralField::create('SignUpButton', '<input type="button" class="' . $config->CcSubmitButtonClasses . '" id="subscribe_to_cc_list" value="' . ($config->CcSubmitButtonText ? $config->CcSubmitButtonText : "Sign Up") . '" />'))); if ($config->CcDisplayZip) { //if postcode field is needed. $fields->push(TextField::create('postcode')->setTitle('')->addExtraClass('form-control ' . $config->CcInputFieldClasses)->setAttribute('placeholder', 'Postcode')); } // Create actions $actions = new FieldList(FormAction::create('signup')->addExtraClass('small button')); $form = new Form($this, 'SS_ConstantContactSignup', $fields, $actions); $form->addExtraClass('custom constant-contect-signup'); // Load the form with previously sent data $form->loadDataFrom(Controller::curr()->getRequest()->postVars()); return $form; }
/** * Presents a form to select a language to translate the pages selected with batch actions into. * * @param string $pageIDs | null * @return Form $form */ public function TranslatePagesForm($pageIDs = null) { Versioned::reading_stage('Stage'); // Needs this for changes to effect draft tree $languages = array_combine(Translatable::get_allowed_locales(), Translatable::get_allowed_locales()); $action = FormAction::create('doTranslatePages', 'Translate')->setUseButtonTag('true')->addExtraClass('ss-ui-button ss-ui-action-constructive batch-form-actions')->setUseButtonTag(true); $actions = FieldList::create($action); $allFields = new CompositeField(); $allFields->addExtraClass('batch-form-body'); if ($pageIDs == null) { $pageIDs = $this->getRequest()->getVar('PageIDs'); } else { $allFields->push(new LiteralField("ErrorParent", '<p class="message bad">Invalid parent selected, please choose another</p>')); } $allFields->push(new HiddenField("PageIDs", "PageIDs", $pageIDs)); $allFields->push(CheckboxSetField::create("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $languages)); $allFields->push(OptionsetField::create("DuplicateChildren", _t('Translatable.DUPECHILDREN', 'Duplicate Children'), array('true' => 'Yes', 'false' => 'No'))); $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="">%s</h3>', _t('HtmlEditorField.MOVE', 'Choose Language...')))); $headings->addExtraClass('cms-content-header batch-pages'); $fields = new FieldList($headings, $allFields); $form = Form::create($this, 'TranslatePagesForm', $fields, $actions); return $form; }
public function __construct($controller) { $versions = $controller->getManifest()->getAllVersions(); $entities = $controller->getManifest()->getEntities(); $q = ($q = $controller->getSearchQuery()) ? $q->NoHTML() : ""; // klude to take an array of objects down to a simple map $entities = $entities->map('Key', 'Title'); // if we haven't gone any search limit then we're searching everything $searchedEntities = $controller->getSearchedEntities(); if (count($searchedEntities) < 1) { $searchedEntities = $entities; } $searchedVersions = $controller->getSearchedVersions(); if (count($searchedVersions) < 1) { $searchedVersions = $versions; } $fields = FieldList::create(TextField::create('q', _t('DocumentationViewer.KEYWORDS', 'Keywords'), $q), CheckboxSetField::create('Versions', _t('DocumentationViewer.VERSIONS', 'Versions'), $versions, $searchedVersions)); $actions = FieldList::create(FormAction::create('results', _t('DocumentationViewer.SEARCH', 'Search'))); $required = RequiredFields::create(array('Search')); parent::__construct($controller, 'AdvancedSearchForm', $fields, $actions, $required); $this->disableSecurityToken(); $this->setFormMethod('GET'); $this->setFormAction($controller->Link('results')); }
/** * Get the composite field necessary for generating the subscription options * * @return FormField */ public function getMailChimpField() { // Add subscription settings for mailchimp // Get list of available groups // @see APES::getAvailableGroups $prefix = $this->owner->config()->mailchimp_form_prefix; // Show notice if pending if ($this->isPending()) { return LiteralField::create("{$prefix}[Pending]", "<p class='mailchimp-pending'>Your subscription is currently pending email verification.<br />" . "Please check your email and verify to confirm.</p>"); } $field = CompositeField::create(HiddenField::create("{$prefix}[Enabled]", false, 1))->addExtraClass('mailchimp-options'); // Generate fields for all groups $groups = $this->getMailChimpGroups(); foreach ($groups as $mailGroup) { $groupID = $mailGroup['id']; // Determine field to use if ($mailGroup['type'] === 'checkboxes') { $field->push(CheckboxSetField::create("{$prefix}[Groups][{$groupID}]", $mailGroup['name'], $mailGroup['values'], $mailGroup['selected'])->addExtraClass('mailchimp-option')); } else { // Not implemented user_error('Mailchimp group type ' . $mailGroup['type'] . ' not implemented', E_USER_WARNING); } } // If there are no groups, replace all subscriptions with a single checkbox if (empty($groups)) { $field->push(CheckboxField::create("{$prefix}[Subscribed]", "I wish to subscribe for email updates", $this->isSubscribed())->addExtraClass('mailchimp-subscribe')); } return $field; }
/** * Constructs a FieldList for use in the CMSForm. * * @return FieldList */ public function construct_cms_fields() { //Create the FieldList and push the Root TabSet on to it. $fields = FieldList::create($root = TabSet::create('Root', Tabset::create("Settings", Tabset::create("General", Tab::create("StoreSettings", HeaderField::create("Maintenance Mode"), CompositeField::create(DropdownField::create("StoreSettings_StoreAvailable", "Store Status", array("1" => "Live", "2" => "Down for Maintenance (show the below message)")), TextareaField::create("StoreSettings_StoreAvailableMessage", "Maintenance Message")->setRightTitle("The message to display to visitors whilst your store is in maintenance mode.")), HeaderField::create("Store Details"), CompositeField::create(TextField::create("StoreSettings_StoreName", "Store Name")->setRightTitle("i.e. Steve's Shoe Shop."), TextareaField::create("StoreSettings_StoreAddress", "Store Address")->setRightTitle("<strong>Example</strong><br />123 ACME Drive<br />Enfield<br />London</br />EN1 1YQ"), CountryDropdownField::create("StoreSettings_StoreCountry", "Store Country")), HeaderField::create("Product Measurements"), CompositeField::create(DropdownField::create("StoreSettings_ProductWeight", "Product Weight", array("Pounds" => "Pounds", "Ounces" => "Ounces", "Grams" => "Grams", "Kilograms" => "Kilograms", "Tonns" => "Tonns"))->setRightTitle("Select the weight measurement you wish to use in your store."), DropdownField::create("StoreSettings_ProductDimensions", "Product Dimensions", array("Inches" => "Inches", "Millimetres" => "Millimetres", "Centimetres" => "Centimetres"))->setRightTitle("Select the width, height and length measurement you wish to use in your store.")), HeaderField::create("SSL"), CompositeField::create(LiteralField::create("SSL_LiteralField", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t\t\t<strong>IMPORTANT:</strong><br />\n\t\t\t\t\t\t\t\t\t\t\tIn order to protect your customers personally identifiable information it is\n\t\t\t\t\t\t\t\t\t\t\tstrongly recommended that you consider installing an SSL certificate for your website.\n\t\t\t\t\t\t\t\t\t\t\t<br />If you are unsure on how to do this please reach out to the party responsible\n\t\t\t\t\t\t\t\t\t\t\tfor this website. \n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tEnabling the option below will ensure all communications between third-party providers\n\t\t\t\t\t\t\t\t\t\tare transmitted over the https:// protocol.\n\t\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("StoreSettings_SSLToggle", "Yes, I have SSL enabled."))), Tab::create("DisplaySettings", HeaderField::create("General Display Settings"), CompositeField::create(NumericField::create("DisplaySettings_FeaturedProducts", "Featured Products")->setRightTitle("Enter the number of products you wish to display in the Featured Products panels."), NumericField::create("DisplaySettings_NewProducts", "New Products")->setRightTitle("Enter the number of products you wish to display in the New Products panels."), DropdownField::create("DisplaySettings_CartQuantity", "Cart Quantity Selection", array("1" => "Dropdown", "2" => "Textbox"))->setRightTitle("Select how you wish the quantity selector to be shown on the product pages.")), HeaderField::create("Product Display Settings"), CompositeField::create(CheckboxField::create("DisplaySettings_ShowPrice", "Show product prices im my store."), CheckboxField::create("DisplaySettings_ShowSKU", "Show product SKUs in my store."), CheckboxField::create("DisplaySettings_ShowWeight", "Show product weights in my store."), CheckboxField::create("DisplaySettings_ShowDimensions", "Show product dimensions in my store."), DropdownField::create("DisplaySettings_ProductSort", "Default Product Sort", array("Title ASC" => "Product Name Ascending", "Title DESC" => "Product Name Descending", "SalePrice ASC, RegularPrice ASC" => "Price Lowest to Highest", "SalePrice DESC, RegularPrice DESC" => "Price Highest to Lowest", "Created ASC" => "Oldest First", "Created DESC" => "Newest First"))), HeaderField::create("Product Photo Display Settings"), CompositeField::create(LiteralField::create("ProductPagePhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Page Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for the main photo on a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductPagePhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductPagePhotoHeight", "Width (pixels)")), LiteralField::create("ProductThumbnailPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Thumbnail Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for product thumbnails throughout the store.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductThumbnailPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductThumbnailPhotoHeight", "Height (pixels)")), LiteralField::create("ProductEnlargedPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Enlarged Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for enlarged photos. Users will see this if they click\n\t\t\t\t\t\t\t\t\t\tto see the larger version of a product photo from a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductEnlargedPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductEnlargedPhotoHeight", "Height (pixels)"))))), Tabset::create("Orders", Tab::create("CheckoutSettings", HeaderField::create("Initial Order Status"), CompositeField::create(DropdownField::create("CheckoutSettings_InitialStatus", "Status", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))->setRightTitle("Select the status you wish all new orders to be set to.")), HeaderField::create("Guest Checkout"), CompositeField::create(CheckboxField::create("CheckoutSettings_GuestCheckout", "Allow customers to checkout as a guest without the need for an account."), CheckboxField::create("CheckoutSettings_GuestCheckoutAccount", "Create an account for customers if they checkout as a guest (if they do not already have one)")), HeaderField::create("Order Comments"), CompositeField::create(CheckboxField::create("CheckoutSettings_OrderComments", "Allow customers to provide a comment with their orders.")), HeaderField::create("Terms & Conditions"), CompositeField::create(CheckboxField::create("CheckoutSettings_TermsAndConditions", "I require my customers to have agreed to terms and conditions before they can place an order."), TreeDropdownField::create("CheckoutSettings_TermsAndConditionsSiteTree", "Terms & Conditions Page", "SiteTree"))), Tab::create("Order Statuses", HeaderField::create("Custom Order Statuses"), CompositeField::create(LiteralField::create("CustomOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section allows you to specify custom order statuses where those out of the box\n\t\t\t\t\t\t\t\t\t\tdo not otherwise match your businesses requirements.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("CustomOrderStatus", "", DataObject::get("Order_Statuses", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Order Statuses"), CompositeField::create(LiteralField::create("DefaultOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section displays the default order statuses that are used throughout the store. Feel free\n\t\t\t\t\t\t\t\t\t\tto alter their Display Name and Descriptions to suit the needs of your business.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("DefaultOrderStatus", "", DataObject::get("Order_Statuses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("EmailNotifications", HeaderField::create("Send store emails from"), CompositeField::create(EmailField::create("EmailNotification_SendEmailsFrom", "From Email Address")->setRightTitle("\n\t\t\t\t\t\t\t\t\tThis is the address that is used in the 'From' section of all automatically generated emails.<br />\n\t\t\t\t\t\t\t\t\t<strong>SMTP Users:</strong> If you are using a SilverStripe SMTP module it is strongly recommended\n\t\t\t\t\t\t\t\t\tyou set this value to that of the authenticated SMTP email address.")), HeaderField::create("New order notifications"), CompositeField::create(EmailField::create("EmailNotification_AdminNewOrder", "Admin Notification Email")->setRightTitle("When the store receives a new order send a notification to the above address.")), HeaderField::create("Send the customer an email when"), CompositeField::create(CheckboxField::create("EmailNotification_AccountCreated", "They create an account."), CheckboxField::create("EmailNotification_OrderPlaced", "They place an order with my store.")), HeaderField::create("Send the customer an email when their order status changes to"), CompositeField::create(CheckboxSetField::create("EmailNotification_OrderStatuses", "Pick your desired statuses", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))))), Tab::create("Stock", HeaderField::create("Stock Management"), CompositeField::create(LiteralField::create("StockManagement_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t<strong>What is Stock Management?</strong><br />\n\t\t\t\t\t\t\t\t\tStock management is designed to keep tabs on your stock levels. If enabled, stock levels will be\n\t\t\t\t\t\t\t\t\tmanaged by the store and automatically decremented upon receiving a successful order.<br />\n\t\t\t\t\t\t\t\t\tIt will also prevent customers from placing an order for a product if it is deemed to\n\t\t\t\t\t\t\t\t\tbe out of stock.\n\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("Stock_StockManagement", "Enable stock control in my store.")), HeaderField::create("Pending Orders"), CompositeField::create(LiteralField::create("PendingOrders_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tEnter the number of minutes that stock allocated to unpaid orders will be held before the \n\t\t\t\t\t\t\t\t\tassociated order is cancelled and held stock is made available to other customers.\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("Stock_PendingOrdersFreezeStock", ""))), HeaderField::create("Stock Levels"), CompositeField::create(FieldGroup::create(NumericField::create("Stock_LowStockThreshold", "Low Stock Threshold")->setRightTitle("The stock level considered as low."), NumericField::create("Stock_OutOfStockThreshold", "Out of Stock Threshold")->setRightTitle("The stock level considered as out of stock."), TextField::create("Stock_OutofStockMessage", "Out of Stock Message")->setRightTitle("The message to display when a product is out of stock.")), DropdownField::create("Stock_ProductOutOfStock", "Product Out of Stock", array("1" => "Completely hide the product from my store", "2" => "Hide the product but allow the product page to be accessed from its URL", "3" => "Do not make any changes"))->setRightTitle("Select what you wish to happen when a product is out of stock."), DropdownField::create("Stock_StockLevelDisplay", "Stock Level Display", array("1" => "Always show stock levels", "2" => "Show stock levels after the product drops below the low stock threshold", "3" => "Never show stock levels"))->setRightTitle("Select how you would like stock levels to appear in your store."))), Tab::create("Couriers", HeaderField::create("Couriers"), CompositeField::create(GridField::create("CourierSettings", "", DataObject::get("Courier", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Gateways", HeaderField::create("Gateways"), CompositeField::create(GridField::create("GatewaySettings", "", DataObject::get("Gateway", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Currency", HeaderField::create("Accepted Currencies"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tYou can define additional currencies in this section. Customers will be shown prices in their\n\t\t\t\t\t\t\t\t\tselected currency throughout the store but will transact in your local currency.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_AcceptedCurrencies", "", DataObject::get("StoreCurrency", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Local (Default) Currency"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tConfigure your store's local (default) currency in this section.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_LocalCurrency", "", DataObject::get("StoreCurrency", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tabset::create("Tax", Tab::create("TaxSettings", HeaderField::create("Tax Settings"), CompositeField::create(DropdownField::create("TaxSettings_InclusiveExclusive", "Product Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_ShippingInclusiveExclusive", "Shipping Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_CalculateUsing", "Calculate Tax Using", array("1" => "Billing Address", "2" => "Shipping Address", "3" => "Store Address")))), Tab::create("TaxClasses", HeaderField::create("Other Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax class allows you to define tax categories.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesOther", "", DataObject::get("TaxClasses", "(0=SystemCreated)", "ID ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThese are the default tax classes.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesDefault", "", DataObject::get("TaxClasses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("TaxZones", HeaderField::create("Other Tax Zones"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax Zone allows you to define Tax rules on a country by country basis.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_Zones", "", DataObject::get("TaxZones", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Zone"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis is the default tax zone applies where no zone exists for a customers' country.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ZonesDefault", "", DataObject::get("TaxZones", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction"))))), Tab::create("Reviews", HeaderField::create("Product Reviews"), CompositeField::create(CheckboxField::create("ProductReviewSettings_EnableReviews", "Enable product reviews in my store."), CheckboxField::create("ProductReviewSettings_ApprovedPurchaserOnly", "Require a customer to have purchased an item before making a review."), CheckboxField::create("ProductReviewSettings_AdminApproval", "Require admin approval before reviews are made visible."))))), HiddenField::create('ID', false, 0)); //Tab nav in CMS is rendered through separate template $root->setTemplate('CMSTabSet'); return $fields; }
public function AddonsSearchForm() { $form = new Form($this, 'AddonsSearchForm', new FieldList(array(TextField::create('search', 'Search for')->setValue($this->request->getVar('search'))->addExtraClass('input-block-level'), DropdownField::create('sort', 'Sort by')->setSource(array('name' => 'Name', 'downloads' => 'Most downloaded', 'newest' => 'Newest'))->setEmptyString('Best match')->setValue($this->request->getVar('sort'))->addExtraClass('input-block-level'), DropdownField::create('type', 'Add-on type')->setSource(array('module' => 'Modules', 'theme' => 'Themes'))->setEmptyString('Modules and themes')->setValue($this->request->getVar('type'))->addExtraClass('input-block-level'), CheckboxSetField::create('compatibility', 'Compatible SilverStripe versions')->setSource(SilverStripeVersion::get()->map('Name', 'Name'))->setValue($this->request->getVar('compatibility'))->setTemplate('AddonsSearchCheckboxSetField'))), new FieldList()); return $form->setFormMethod('GET')->setFormAction($this->Link()); }
private function Fields() { return FieldList::create(TextField::create('Title'), TextField::create('Subtitle'), CheckboxField::create("IsTrue"), CheckboxSetField::create('CheckboxSet', 'Options', array('Opt1' => 'Opt1', 'Opt2' => 'Opt2', 'Opt3' => 'Opt3', 'Opt4' => 'Opt4', 'Opt5' => 'Opt5')), DropdownField::create('DDP', 'Choose an item', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'))->setEmptyString('(Select one)'), GroupedDropdownField::create('DDP2', 'Choose an item', array('Group1' => array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'Group2' => array('ITEM6' => 'Item 6', 'ITEM7' => 'Item 7', 'ITEM8' => 'Item 8', 'ITEM9' => 'Item 9', 'ITEM0' => 'Item 0')))->setEmptyString('(Select one)'), ListboxField::create('lbf', 'Choose items', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3'), LookupField::create('lf', 'Look up field', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3')->setEmptyString('(Select one)'), NullableField::create(TextField::create("nf", "Field 1", "abc")), NullableField::create(CheckBoxField::create("nf2", "Field 1", "abc")), NumericField::create("nf3", "NumericField", 10), NumericField_Readonly::create('NFR1', 'NumericField_Readonly'), OptionsetField::create($name = "op", $title = "OptionsetField", $source = array("1" => "Option 1", "2" => "Option 2", "3" => "Option 3", "4" => "Option 4", "5" => "Option 5"), $value = "3"), ReadonlyField::create('rf1', 'read only field', 'value'), TextareaField::create($name = "description", $title = "Description", $value = "This is the default description"), DateField::create('datefield', 'Date Field')->setConfig('showcalendar', true), TimeField::create('timeField', 'Time Field', '12am')); }
/** * Setup the fields that are visible ONLY when the item exists already. * @param News $owner * @param SiteConfig $siteConfig */ private function existingItem(News $owner, SiteConfig $siteConfig) { if (!$owner->ID) { $member = Member::currentUser(); $this->field_list['Root.Main'][13] = ReadonlyField::create('Tags', $owner->fieldLabel('Tags'), _t('News.TAGAFTERID', 'Tags can be added after the item has been saved')); $owner->Type = 'news'; $owner->Author = $member->FirstName . ' ' . $member->Surname; } else { if (class_exists('MultiSelectField')) { /** I like multiselectfield and needed a reason to commit something */ $this->field_list['Root.Main'][13] = MultiSelectField::create('Tags', $owner->fieldLabel('Tags'), $this->owner); } else { $this->field_list['Root.Main'][13] = CheckboxSetField::create('Tags', $owner->fieldLabel('Tags'), Tag::get()->map('ID', 'Title')); } $this->field_list['Root.Main'][2] = LiteralField::create('Dummy', '<div id="Dummy" class="field readonly"> <label class="left" for="Form_ItemEditForm_Dummy">Link</label> <div class="middleColumn"> <span id="Form_ItemEditForm_Dummy" class="readonly"> <a href="' . $owner->AbsoluteLink() . '" target="_blank">' . $owner->AbsoluteLink() . '</a> </span> </div> </div>'); if ($siteConfig->EnableSlideshow) { /** @var GridFieldConfig_RecordEditor $gridFieldConfig */ $gridFieldConfig = GridFieldConfig_RecordEditor::create(); $gridFieldConfig->addComponent(new GridFieldBulkUpload()); $gridFieldConfig->addComponent(new GridFieldOrderableRows('SortOrder')); $gridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getRootFolderName($siteConfig)); if (class_exists('GridFieldGalleryTheme')) { $gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image')); /** * as gallery theme breaks sorting with GridFieldOrderableRows * let's use SortableRows as a fallback when installed * * @todo remove later this when gridfield extension works with gallery theme */ if (class_exists('GridFieldSortableRows')) { $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder')); $gridFieldConfig->removeComponentsByType('GridFieldOrderableRows'); } } $this->field_list['Root'][] = Tab::create('SlideshowImages', $owner->fieldLabel('SlideshowImages'), GridField::create('SlideshowImage', _t('News.IMAGES', 'Slideshow images'), $owner->SlideshowImages()->sort('SortOrder'), $gridFieldConfig)); } } }
/** * 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', Tabset::create("Product", Tab::create("Details", HeaderField::create("General"), CompositeField::create(TextField::create("Title", "Product Name"), NumericField::create("RegularPrice", "Regular Price (" . $this->getDefaultCurrency() . ")")->setRightTitle("The standard price for this product in your store."), FieldGroup::create("Other Prices (" . $this->getDefaultCurrency() . ")", NumericField::create("SalePrice", "Sale Price (optional)")->setRightTitle("If entered, this price will replace the regular price."), NumericField::create("RetailPrice", "Recommended Retail Price (optional)")->setRightTitle("If entered, the retail price will be indicated on your site."), NumericField::create("CostPrice", "Cost Price (optional)")->setRightTitle("Not displayed on your site. For your reference only."))), HeaderField::create("Photos (optional)"), CompositeField::create($this->exists() ? UploadField::create("Images", "Product Photos")->setAllowedFileCategories('image')->setAllowedMaxFileNumber(4)->setFolderName('product-photos') : LiteralField::create($title = "Product Photos", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tYou will be able to add photos to this product after clicking create.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")), HeaderField::create("Product Description (optional)"), CompositeField::create(HtmlEditorField::create("Description", ""))->addExtraClass("TorindulCompositeField TorindulCompositeField_16Margin"), HeaderField::create("Stock Levels")->addExtraClass("TorindulHeaderField TorindulCompositeField_16Margin"), CompositeField::create(NumericField::create("StockLevel", "Current Stock Level")->setRightTitle("Total quantity currently in stock.")), HeaderField::create("Availability"), CompositeField::create(DropdownField::create("EnablePurchases", "Enable Purchase?", array("1" => "Yes, allow customers to purchase this product.", "0" => "No, do not allow customers to purchase this product.")), DropdownField::create("Visible", "Visible to Customers?", array("1" => "Yes, allow my customers to see this product in my store.", "0" => "No, hide this product from customers."))), HeaderField::create("Miscellaneous"), CompositeField::create(DB::query("SELECT COUNT(*) FROM Product_Brands")->value() < 1 ? LiteralField::create($title = "Brand (optional)", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tBefore you can select a product brand you must first create one. \n\t\t\t\t\t\t\t\t\t\t\tPlease return to the previous screen and review the brands tab.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : DropdownField::create("Brand", "Brand (optional)", DataObject::get("Product_Brands", "", "Title ASC")->map("ID", "Title"))->setEmptyString('(Select one)')->setRightTitle("Specify this products brand, if applicable."), DB::query("SELECT COUNT(*) FROM Product_Categories")->value() < 1 ? LiteralField::create($title = "Categories (optional)", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tBefore you can select one or more product categories you must first create them. \n\t\t\t\t\t\t\t\t\t\t\tPlease return to the previous screen and review the categories tab.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : CheckboxSetField::create("Categories", "Categories (optional)", DataObject::get("Product_Categories", "", "Title ASC")->map("ID", "Title")), DropdownField::create("TaxClass", "Tax Class", DataObject::get("TaxClasses", "", "Title ASC")->map("ID", "Title")), TextField::create("SKU", "SKU/Product Code (optional)"), OptionsetField::create("Featured", "Featued Product", array("0" => "No", "1" => "Yes"))->setRightTitle("When set to yes this product will appear as a 'Featured Product' in your storefront."), FieldGroup::create($title = "Measurements", TextField::create("Width", "Width (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Height", "Height (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Length", "Length (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Weight", "Weight (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductWeight)))), Tab::create("CustomFields", HeaderField::create("Custom Fields"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\tCustom fields allow you to specify additional information that will appear on the product's page,\n\t\t\t\t\t\t\t\t\tsuch as a book's ISBN or a DVD's release date.\n\t\t\t\t\t\t\t\t</div>"), $this->exists() ? GridField::create("CustomFields", "", $this->ProductCustomFields()->sort("Title ASC"), GridFieldConfig_RecordEditor::create()) : LiteralField::create($title = "CustomFieldsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\tYou will be able to add custom fields to this product after clicking create.\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title))), Tab::create("Reviews", HeaderField::create("Product Reviews"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\t\tAccording to Reevoo, reviews produce an average 18% uplift in sales and 50 or more reviews per \n\t\t\t\t\t\t\t\t\t\tproduct can mean a 4.6% increase in conversion rates.\n\t\t\t\t\t\t\t\t\t</div>"), $this->checkReviewsEnabled() ? $this->exists() ? GridField::create("ProductReviews", "", $this->ProductReviews()->sort("Date DESC")) : LiteralField::create($title = "CustomFieldsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tYou will be able to manage reviews for this product after clicking create.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : LiteralField::create($title = "ReviewsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-exclamation-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tProduct reviews are currently disabled for your store. You can enable them in store settings.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")->setRightTitle($title)))))); return $fields; }
/** * Filters for order admin area search. * * @see DataObject::scaffoldSearchFields() * @return FieldSet */ public function scaffoldSearchFields($params = array()) { $fields = parent::scaffoldSearchFields(); $request = Controller::curr()->getRequest(); $query = $request->requestVar('q'); $statusVal = isset($query['Status']) ? $query['Status'] : array(); $fields->push(CheckboxSetField::create('Status', 'Status', array('Pending' => 'Pending', 'Processing' => 'Processing', 'Dispatched' => 'Dispatched'))->setValue($statusVal)); return $fields; }
public function EnquiryForm() { if (!Email::validEmailAddress($this->EmailTo) || !Email::validEmailAddress($this->EmailFrom)) { return false; } if (!$this->EmailSubject) { $this->EmailSubject = 'Website Enquiry'; } $elements = $this->EnquiryFormFields(); /* empty form, return nothing */ if ($elements->count() == 0) { return false; } /* Build the fieldlist */ $fields = FieldList::create(); $validator = RequiredFields::create(); $jsValidator = array(); /* Create filter for possible $_GET parameters / pre-population */ $get_param_filter = FileNameFilter::create(); foreach ($elements as $el) { $key = $this->keyGen($el->FieldName, $el->SortOrder); $field = false; $type = false; if ($el->FieldType == 'Text') { if ($el->FieldOptions == 1) { $field = TextField::create($key, htmlspecialchars($el->FieldName)); } else { $field = TextareaField::create($key, htmlspecialchars($el->FieldName)); $field->setRows($el->FieldOptions); } } elseif ($el->FieldType == 'Email') { $field = EmailField::create($key, htmlspecialchars($el->FieldName)); } elseif ($el->FieldType == 'Select') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = DropdownField::create($key, htmlspecialchars($el->FieldName), $tmp); $field->setEmptyString('[ Please Select ]'); } } elseif ($el->FieldType == 'Checkbox') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = CheckboxSetField::create($key, htmlspecialchars($el->FieldName), $tmp); } } elseif ($el->FieldType == 'Radio') { $options = preg_split('/\\n\\r?/', $el->FieldOptions, -1, PREG_SPLIT_NO_EMPTY); if (count($options) > 0) { $tmp = array(); foreach ($options as $o) { $tmp[trim($o)] = trim($o); } $field = OptionsetField::create($key, htmlspecialchars($el->FieldName), $tmp); } } elseif ($el->FieldType == 'Header') { if ($el->FieldOptions) { $field = LiteralField::create(htmlspecialchars($el->FieldName), '<h4>' . htmlspecialchars($el->FieldName) . '</h4> <p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>'); } else { $field = HeaderField::create(htmlspecialchars($el->FieldName), 4); } } elseif ($el->FieldType == 'Note') { if ($el->FieldOptions) { $field = LiteralField::create(htmlspecialchars($el->FieldName), '<p class="note">' . nl2br(htmlspecialchars($el->FieldOptions)) . '</p>'); } else { $field = LiteralField::create(htmlspecialchars($el->FieldName), '<p class="note">' . htmlspecialchars($el->FieldName) . '</p>'); } } if ($field) { /* Allow $_GET parameters to pre-populate fields */ $request = $this->request; $get_var = $get_param_filter->filter($el->FieldName); if (!$request->isPOST() && !$field->Value() && null != $request->getVar($get_var)) { $field->setValue($request->getVar($get_var)); } if ($el->RequiredField == 1) { $field->addExtraClass('required'); /* Add "Required" next to field" */ $validator->addRequiredField($key); $jsValidator[$key] = $el->FieldType; } if ($el->PlaceholderText) { $field->setAttribute('placeholder', $el->PlaceholderText); } $fields->push($field); } } if ($this->AddCaptcha) { $label = $this->CaptchaLabel; $field = CaptchaField::create('CaptchaImage', $label); $field->addExtraClass('required'); $validator->addRequiredField('CaptchaImage'); $jsValidator['CaptchaImage'] = 'Text'; if ($this->CaptchaHelp) { $field->setRightTitle('<span id="CaptchaHelp">' . htmlspecialchars($this->CaptchaHelp) . '</span>'); } $fields->push($field); } $actions = FieldList::create(FormAction::create('SendEnquiryForm', $this->EmailSubmitButtonText)); if (Config::inst()->get('EnquiryPage', 'js_validation')) { Requirements::customScript('var EnquiryFormValidator=' . json_encode($jsValidator) . ';'); Requirements::javascript(basename(dirname(dirname(__FILE__))) . '/javascript/enquiryform.js'); } $form = Form::create($this, 'EnquiryForm', $fields, $actions, $validator); return $form; }
public function testValidationWithDataList() { //test with datalist input $checkboxTestArticle = $this->objFromFixture('CheckboxSetFieldTest_Article', 'articlewithtags'); $tag1 = $this->objFromFixture('CheckboxSetFieldTest_Tag', 'tag1'); $tag2 = $this->objFromFixture('CheckboxSetFieldTest_Tag', 'tag2'); $tag3 = $this->objFromFixture('CheckboxSetFieldTest_Tag', 'tag3'); $field = CheckboxSetField::create('Test', 'Testing', $checkboxTestArticle->Tags()->map()); $validator = new RequiredFields(); $field->setValue(array($tag1->ID => $tag1->ID, $tag2->ID => $tag2->ID)); $this->assertTrue($field->validate($validator), 'Validates values in source map'); //invalid value should fail $fakeID = CheckboxSetFieldTest_Tag::get()->max('ID') + 1; $field->setValue(array($fakeID => $fakeID)); $this->assertFalse($field->validate($validator), 'Field does not valid values outside of source map'); //non valid value included with valid options should succeed $field->setValue(array($tag1->ID => $tag1->ID, $tag2->ID => $tag2->ID, $tag3->ID => $tag3->ID)); $this->assertFalse($field->validate($validator), 'Field does not validate when presented with mixed valid and invalid values'); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', CheckboxSetField::create('ApplicableDays', 'Schedule Days', array('Mon' => 'Monday', 'Tue' => 'Tuesday', 'Wed' => 'Wednesday', 'Thu' => 'Thursday', 'Fri' => 'Friday', 'Sat' => 'Saturday', 'Sun' => 'Sunday'))); return $fields; }