public function testNumberTypeOnInputHtml()
 {
     $field = new NumericField('Number');
     $html = $field->Field();
     $this->assertContains('type="number"', $html, 'number type set');
     $this->assertContains('step="any"', $html, 'step value set to any');
 }
예제 #2
0
 /**
  * @param string $name
  * @param string $title
  *
  * @return NumericField
  */
 protected function getNumericField($name, $title)
 {
     $field = new NumericField($name, $title);
     $field->setAttribute("type", "number");
     $field->setAttribute("min", 0);
     return $field;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Capacity');
     $fields->removeByName('Registrations');
     $fields->removeByName('Tickets');
     $fields->removeByName('EmailReminder');
     $fields->removeByName('RemindDays');
     $fields->removeByName('PaymentID');
     $fields->removeByName('ReminderJobID');
     if (!$this->isInDB()) {
         $fields->push(new LiteralField('RegistrationNote', '<p>You can configure registration once ' . 'you save for the first time.</p>'));
         return $fields;
     }
     $fields->push(new GridField('Tickets', _t('EventManagement.AVAILABLE_TICKETS', 'Available Tickets'), $this->Tickets(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent($add = new GridFieldAddExistingSearchButton())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($editable = new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction(true))));
     $fields->push($capacity = new NumericField('Capacity', _t('EventManagement.CAPACITY', 'Capacity')));
     $editable->setDisplayFields(array('Title' => array('title' => 'Title', 'field' => 'ReadonlyField'), 'StartSummary' => 'Sales Start', 'PriceSummary' => 'Price', 'Available' => array('field' => 'NumericField')));
     $add->setTitle(_t('EventManagement.ADD_TICKET_TYPE', 'Add Ticket Type'));
     $capacity->setDescription('Set to 0 for unlimited capacity.');
     if (class_exists('AbstractQueuedJob')) {
         if ($this->ReminderJobID && $this->ReminderJob()->StepsProcessed) {
             $fields->push(new LiteralField('RemindersAlreadySent', '<p>Reminder emails have already been sent out.</p>'));
         } else {
             $fields->push(new CheckboxField('EmailReminder', _t('EventManagement.SEND_REMINDER_EMAIL', 'Send the registered attendees a reminder email?')));
             $fields->push($remindDays = new NumericField('RemindDays', _t('EventManagement.SEND_REMINDER', 'Send reminder')));
             $remindDays->setDescription(_t('EventManagement.DAYS_BEFORE_EVENT', 'Days before the event starts.'));
         }
     }
     return $fields;
 }
예제 #4
0
파일: FlexSlide.php 프로젝트: vinstah/body
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName("FlexSliderID");
     // Main
     $field_Picture = new UploadField('Picture', _t("FlexSlider.Picture"));
     $field_Picture->setFolderName("FlexSlides");
     $field_Picture->setConfig('allowedMaxFileNumber', 1);
     $field_Position = new NumericField("Position", _t("FlexSlider.Position"));
     $field_Position->RightTitle(_t("FlexSlider.PositionExplain"));
     $field_SlideTitle = new TextField("SlideTitle", _t("FlexSlider.Title"));
     $field_SlideDescription = new TextField("SlideDescription", _t("FlexSlider.Description"));
     $field_HeadlineLinks = new HeaderField("HeadlineLinks", _t("FlexSlider.HeadlineLinks"));
     $field_InternalLink = new TreeDropdownField("InternalLinkID", _t('FlexSlider.InternalLink'), 'SiteTree');
     $field_removeInternalLink = new CheckboxField("doRemoveInternalLink", _t("FlexSlider.doRemoveInternalLink"));
     $field_ExternalLink = new TextField("ExternalLink", _t("FlexSlider.or") . " " . _t("FlexSlider.ExternalLink"));
     $field_HeadlineEnabled = new HeaderField("HeadlineEnabled", _t("FlexSlider.HeadlineEnabled"));
     $field_isEnabled = new CheckboxField("isEnabled", _t("FlexSlider.isEnabled"));
     $FieldsArray = array($field_Position, $field_Picture, $field_SlideTitle, $field_SlideDescription, $field_InternalLink, $field_removeInternalLink, $field_ExternalLink, $field_HeadlineEnabled, $field_isEnabled);
     $fields->addFieldToTab('Root.Main', $field_Position);
     $fields->addFieldToTab('Root.Main', $field_Picture);
     $fields->addFieldToTab('Root.Main', $field_SlideTitle);
     $fields->addFieldToTab('Root.Main', $field_SlideDescription);
     $fields->addFieldToTab('Root.Main', $field_HeadlineLinks);
     $fields->addFieldToTab('Root.Main', $field_InternalLink);
     $fields->addFieldToTab('Root.Main', $field_removeInternalLink);
     $fields->addFieldToTab('Root.Main', $field_ExternalLink);
     $fields->addFieldToTab('Root.Main', $field_HeadlineEnabled);
     $fields->addFieldToTab('Root.Main', $field_isEnabled);
     return $fields;
 }
 /**
  * @param String $label
  * @return NumericField
  */
 public function getQuantityField($label = '')
 {
     $f = new NumericField("Product[{$this->owner->ID}][Quantity]", $label);
     $f->setAttribute('type', Config::inst()->get('GroupedCartFormChildHooks', 'quantity_field_type'));
     $f->setAttribute('min', '0');
     $f->addExtraClass('grouped-quantity');
     return $f;
 }
 public function getSettingsFields()
 {
     $fields = parent::getSettingsFields();
     Requirements::javascript('eventmanagement/javascript/cms.js');
     $fields->addFieldsToTab('Root.Registration', array(new CheckboxField('OneRegPerEmail', _t('EventManagement.ONE_REG_PER_EMAIL', 'Limit to one registration per email address?')), new CheckboxField('RequireLoggedIn', _t('EventManagement.REQUIRE_LOGGED_IN', 'Require users to be logged in to register?')), $limit = new NumericField('RegistrationTimeLimit', _t('EventManagement.REG_TIME_LIMIT', 'Registration time limit'))));
     $limit->setDescription(_t('EventManagement.REG_TIME_LIMIT_NOTE', 'The time limit to complete registration, in seconds. Set to 0 to disable place holding.'));
     $fields->addFieldsToTab('Root.Email', array(new EmailField('EventManagerEmail', _t('EventManagement.EMAIL_EVENT_MANAGER', 'Event manager email to receive registration notifications?')), new CheckboxField('RegEmailConfirm', _t('EventManagement.REQ_EMAIL_CONFIRM', 'Require email confirmation to complete free registrations?')), $info = new TextField('EmailConfirmMessage', _t('EventManagement.EMAIL_CONFIRM_INFO', 'Email confirmation information')), $limit = new NumericField('ConfirmTimeLimit', _t('EventManagement.EMAIL_CONFIRM_TIME_LIMIT', 'Email confirmation time limit')), new CheckboxField('UnRegEmailConfirm', _t('EventManagement.REQ_UN_REG_EMAIL_CONFIRM', 'Require email confirmation to un-register?')), new CheckboxField('EmailNotifyChanges', _t('EventManagement.EMAIL_NOTIFY_CHANGES', 'Notify registered users of event changes via email?')), new CheckboxSetField('NotifyChangeFields', _t('EventManagement.NOTIFY_CHANGE_IN', 'Notify of changes in'), singleton('RegistrableDateTime')->fieldLabels(false))));
     $info->setDescription(_t('EventManagement.EMAIL_CONFIRM_INFO_NOTE', 'This message is displayed to users to let them know they need to confirm their registration.'));
     $limit->setDescription(_t('EventManagement.CONFIRM_TIME_LIMIT_NOTE', 'The time limit to conform registration, in seconds. Set to 0 for no limit.'));
     return $fields;
 }
예제 #7
0
 /**
  * @return NumericField
  */
 public function getFormField()
 {
     $field = new NumericField($this->Name, $this->Title);
     $field->addExtraClass('number');
     if ($field->Required) {
         // Required and numeric validation can conflict so add the
         // required validation messages as input attributes
         $errorMessage = $this->getErrorMessage()->HTML();
         $field->setAttribute('data-rule-required', 'true');
         $field->setAttribute('data-msg-required', $errorMessage);
     }
     return $field;
 }
예제 #8
0
 /**
  * Adds our SEO Meta fields to the page field list
  *
  * @since version 1.0.0
  *
  * @param string $fields The current FieldList object
  *
  * @return object Return the FieldList object
  **/
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('HeadTags');
     $fields->removeByName('SitemapImages');
     if (!$this->owner instanceof Page) {
         $fields->addFieldToTab('Root.Page', HeaderField::create('Page'));
         $fields->addFieldToTab('Root.Page', TextField::create('Title', 'Page name'));
     }
     $fields->addFieldToTab('Root.PageSEO', $this->preview());
     $fields->addFieldToTab('Root.PageSEO', TextField::create('MetaTitle'));
     $fields->addFieldToTab('Root.PageSEO', TextareaField::create('MetaDescription'));
     $fields->addFieldToTab('Root.PageSEO', HeaderField::create(false, 'Indexing', 2));
     $fields->addFieldToTab('Root.PageSEO', TextField::create('Canonical'));
     $fields->addFieldToTab('Root.PageSEO', DropdownField::create('Robots', 'Robots', SEO_FieldValues::IndexRules()));
     $fields->addFieldToTab('Root.PageSEO', NumericField::create('Priority'));
     $fields->addFieldToTab('Root.PageSEO', DropdownField::create('ChangeFrequency', 'Change Frequency', SEO_FieldValues::SitemapChangeFrequency()));
     $fields->addFieldToTab('Root.PageSEO', CheckboxField::create('SitemapHide', 'Hide in sitemap? (XML and HTML)'));
     $fields->addFieldToTab('Root.PageSEO', HeaderField::create('Social Meta'));
     $fields->addFieldToTab('Root.PageSEO', CheckboxField::create('HideSocial', 'Hide Social Meta?'));
     $fields->addFieldToTab('Root.PageSEO', DropdownField::create('OGtype', 'Open Graph Type', SEO_FieldValues::OGtype()));
     $fields->addFieldToTab('Root.PageSEO', DropdownField::create('OGlocale', 'Open Graph Locale', SEO_FieldValues::OGlocale()));
     $fields->addFieldToTab('Root.PageSEO', DropdownField::create('TwitterCard', 'Twitter Card', SEO_FieldValues::TwitterCardTypes()));
     $fields->addFieldToTab('Root.PageSEO', $this->SharingImage());
     $fields->addFieldToTab('Root.PageSEO', HeaderField::create('Other Meta Tags'));
     $fields->addFieldToTab('Root.PageSEO', $this->OtherHeadTags());
     $fields->addFieldToTab('Root.PageSEO', HeaderField::create('Sitemap Images'));
     $fields->addFieldToTab('Root.PageSEO', $this->SitemapImagesGrid());
     $fields->addFieldToTab('Root.PageSEO', LiteralField::create(false, '<br><br>Silverstripe SEO v1.0'));
     return $fields;
 }
 /**
  * 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. &pound;, \$, &euro;."), 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 updateCMSFields(FieldList $fields)
 {
     // check if the insertbefore field is present (may be added later, in which case the above
     // fields never get added
     //$insertOnTab = $this->owner->getFilterableArchiveConfigValue('pagination_control_tab');
     //$insertBefore = $this->owner->getFilterableArchiveConfigValue('pagination_insert_before');
     $insertOnTab = Config::inst()->get($this->owner->className, 'pagination_control_tab');
     $insertBefore = Config::inst()->get($this->owner->className, 'pagination_insert_before');
     if (!$fields->fieldByName("{$insertOnTab}.{$insertBefore}")) {
         $insertBefore = null;
     }
     //if($this->owner->getFilterableArchiveConfigValue('datearchive_active')){
     if (Config::inst()->get($this->owner->className, 'datearchive_active')) {
         //$fields->addFieldToTab($this->owner->getFilterableArchiveConfigValue('pagination_control_tab'),
         $fields->addFieldToTab(Config::inst()->get($this->owner->className, 'pagination_control_tab'), DropdownField::create('ArchiveUnit', _t('filterablearchive.ARCHIVEUNIT', 'Archive unit'), array('year' => _t('filterablearchive.YEAR', 'Year'), 'month' => _t('filterablearchive.MONTH', 'Month'), 'day' => _t('filterablearchive.DAY', 'Day'))), $insertBefore);
     }
     $pagerField = NumericField::create("ItemsPerPage", _t("filterablearchive.ItemsPerPage", "Pagination: items per page"))->setRightTitle(_t("filterablearchive.LeaveEmptyForNone", "Leave empty or '0' for no pagination"));
     $fields->addFieldToTab($insertOnTab, $pagerField, $insertBefore);
     //
     // Create categories and tag config
     //
     //		$config = GridFieldConfig_RecordEditor::create();
     //		$config->removeComponentsByType("GridFieldAddNewButton");
     //		$config->addComponent(new GridFieldAddByDBField("buttons-before-left"));
     // Lets just use what others have made already...
     $config = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldAddNewInlineButton('toolbar-header-right'));
     //if($this->owner->getFilterableArchiveConfigValue('categories_active')){
     if (Config::inst()->get($this->owner->className, 'categories_active')) {
         $fields->addFieldToTab($insertOnTab, $categories = GridField::create("Categories", _t("FilterableArchive.Categories", "Categories"), $this->owner->Categories(), $config), $insertBefore);
     }
     //if($this->owner->getFilterableArchiveConfigValue('tags_active')){
     if (Config::inst()->get($this->owner->className, 'tags_active')) {
         $fields->addFieldToTab($insertOnTab, $tags = GridField::create("Tags", _t("FilterableArchive.Tags", "Tags"), $this->owner->Tags(), $config), $insertBefore);
     }
 }
 public function Inputs()
 {
     if (count($this->linkedFields)) {
         return \ArrayList::create();
     }
     $ranged = is_array($this->settings['start']) && count($this->settings['start']) > 1;
     $minName = $ranged ? 'min' : 'value';
     $fields[$minName] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[' . $minName . ']'))];
     $fields[$minName]['Render']->Value = is_array($this->settings['start']) ? $this->settings['start'][0] : $this->settings['start'];
     if ($ranged) {
         $fields['max'] = ['Render' => $this->castedCopy(\NumericField::create($this->Name . '[max]'))];
         $fields['max']['Render']->Value = $this->settings['start'][1];
     }
     $count = 0;
     array_walk($fields, function ($field) use(&$count) {
         if (!isset($field['Handle'])) {
             $field['Handle'] = $count % 2 ? 'upper' : 'lower';
         }
         if (isset($field['Render'])) {
             $field['Render']->removeExtraClass('rangeslider-display')->addExtraClass('rangeslider-linked')->setAttribute('data-rangeslider-handle', $field['Handle']);
         }
         $count++;
     });
     $fields = \ArrayList::create(array_map(function ($field) {
         return \ArrayData::create($field);
     }, $fields));
     if ($this->inputCallback && is_callable($this->inputCallback)) {
         call_user_func_array($this->inputCallback, [$fields]);
     }
     $this->extend('updateInputs', $fields);
     return $fields;
 }
예제 #12
0
 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 getCMSFields()
 {
     $fields = FieldList::create();
     $fields->merge(array(DropdownField::create("BlogID", _t("BlogRecentPostsWidget.Blog", "Blog"), Blog::get()->map()), NumericField::create("NumberOfPosts", _t("BlogRecentPostsWidget.NumberOfPosts", "Number of Posts"))));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", new Tab("Main", TextField::create("Title", "Title"), GridField::create("Slides", "Nivo Slide", $this->Slides(), GridFieldConfig_RecordEditor::create())), new Tab("Advanced", DropdownField::create("Theme", "Theme", self::get_all_themes()), DropdownField::create("Effect", "Effect", $this->dbObject("Effect")->enumValues()), NumericField::create("AnimationSpeed", "Animation Speed")->setDescription("Animation speed in milliseconds."), NumericField::create("PauseTime", "Pause Time")->setDescription("Pause time on each frame in milliseconds."), TextField::create("PrevText", "Previous Text"), TextField::create("NextText", "Next Text"), NumericField::create("Slices", "Slices")->setDescription("Number of slices for slice animation effects."), NumericField::create("BoxCols", "Box Columns")->setDescription("Number of box columns for box animation effects."), NumericField::create("BoxRows", "Box Rows")->setDescription("Number of box rows for box animation effects."), NumericField::create("StartSlide", "Start Slide")->setDescription("Slide to start on (0 being the first)."), HeaderField::create("ControlHeading", "Control Options", 4), CompositeField::create(array(CheckboxField::create("DirectionNav", "Display Direction Navigation?"), CheckboxField::create("ControlNav", "Display Control Navigation?"), CheckboxField::create("ControlNavThumbs", "Use thumbnails for control nav?"), CheckboxField::create("PauseOnHover", "Stop the animation whilst hovering?"), CheckboxField::create("ManualAdvance", "Force manual transition?"), CheckboxField::create("RandomStart", "Random Start?"))))));
     $fields->extend("updateCMSFields", $fields);
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(TextField::create("TwitterHandle", "Twitter Handle"));
     $fields->push(NumericField::create("NumberOfTweets", "Number of Tweets"));
     return $fields;
 }
 function SelectForm()
 {
     $fieldList = new FieldList(NumericField::create("Year", "Manufacturing Year"), DropdownField::create("Make", "Make", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Model", "Model", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Type", "Type", array(0 => $this->pleaseSelectPhrase())), NumericField::create("ODO", "Current Odometer (overall distance travelled - as shown in your dashboard"));
     $actions = new FieldList(FormAction::create("doselectform")->setTitle("Start Calculation"));
     $form = Form::create($this, "SelectForm", $fieldList, $actions);
     return $form;
 }
 /**
  * Constructor.
  *
  * @param string      $name
  * @param null|string $title
  * @param string      $value
  * @param null|array  $options
  */
 public function __construct($name, $title = null, $value = '', array $options = null)
 {
     if ($options) {
         $this->setUIOptions($options);
     }
     parent::__construct($name, $title, $value);
 }
 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 Field()
 {
     $qtyArray = array();
     for ($r = 1; $r <= $this->max; $r++) {
         $qtyArray[$r] = $r;
     }
     return NumericField::create($this->MainID() . '_Quantity', _t('Order.Quantity', "Quantity"), $this->item->Quantity)->setAttribute('type', 'number');
 }
 public function Field()
 {
     $valArr = $this->value ? explode('-', $this->value) : null;
     // fields
     $first = new NumericField($this->name . '[first]', false, $valArr ? array_shift($valArr) : null);
     $first->setMaxLength(3);
     $first->addExtraClass('ird-numeric');
     $second = new NumericField($this->name . '[second]', false, $valArr ? array_shift($valArr) : null);
     $second->setMaxLength(3);
     $second->addExtraClass('ird-numeric');
     $third = new NumericField($this->name . '[third]', false, $valArr ? array_shift($valArr) : null);
     $third->setMaxLength(3);
     $third->addExtraClass('ird-numeric');
     $fields = array($first->Field(), $second->Field(), $third->Field());
     $html = implode('<span style="padding: 0 8px">-</span>', $fields);
     return $html;
 }
 /**
  * Add fields to the CMS for this courier.
  */
 public function getCMSFields()
 {
     //Fetch the fields from the Courier DataObject
     $fields = parent::getCMSFields();
     //Add new fields
     $fields->addFieldsToTab("Root.Main", array(HeaderField::create("Minimum Spend"), CompositeField::create(NumericField::create("MinSpend", "Qualifying Spend (" . Product::getDefaultCurrency() . ")")->setRightTitle("Enter the amount a customer must spend before qualifying for Free Shipping."))));
     return $fields;
 }
 public function formField()
 {
     $field = $this->removeFields(parent::formField(), ['action', 'scheme', 'show_faces', 'share', 'for_kids']);
     $field->push(\DropdownField::create('mobile', _t('Shortcodable.FB-MOBILE', 'Display mobile compatible version'), ['' => '(Automatic)', 'true' => 'Yes', 'false' => 'No']));
     $field->push(\NumericField::create('num_posts', _t('Shortcodable.FB-NUM_POSTS', 'Number of posts'), 30));
     $field->push(\DropdownField::create('order_by', _t('Shortcodable.FB-ORDER_BY', 'Order by'), ['' => 'Social (active)', 'reverse_time' => 'Created DESC', 'time' => 'Created ASC']));
     return $field;
 }
 /**
  * Add fields to the CMS for this courier.
  */
 public function getCMSFields()
 {
     //Fetch the fields from the Courier DataObject
     $fields = parent::getCMSFields();
     //Add new fields
     $fields->addFieldsToTab("Root.Main", array(HeaderField::create("Item Rate"), CompositeField::create(NumericField::create("FlatRate", "Item Rate (" . Product::getDefaultCurrency() . ")")->setRightTitle("Enter a flat rate of shipping to charge for every item in this order."))));
     return $fields;
 }
 public function Field()
 {
     $field = new FieldGroup($this->name);
     $field->setID("{$this->name}_Holder");
     $valueArr = $this->valueArr;
     $valueArr = self::convert_format_nz($valueArr);
     $field->push($n1 = new NumericField($this->name . '[BankCode]', '', $valueArr['BankCode'], 2));
     $field->push($n2 = new NumericField($this->name . '[BranchCode]', '', $valueArr['BranchCode'], 4));
     $field->push($n3 = new NumericField($this->name . '[AccountNumber]', '', $valueArr['AccountNumber'], 8));
     $field->push($n4 = new NumericField($this->name . '[AccountSuffix]', '', $valueArr['AccountSuffix'], 3));
     if ($this->tabIndex) {
         $n1->setTabIndex($this->getTabIndex());
         $n2->setTabIndex($this->getTabIndex() + 1);
         $n3->setTabIndex($this->getTabIndex() + 2);
         $n4->setTabIndex($this->getTabIndex() + 3);
     }
     return $field;
 }
예제 #25
0
 public function newGameForm()
 {
     $fields = new FieldList(NumericField::create('ScoreTeamOne', 'Score Team One'), NumericField::create('ScoreTeamTwo', 'Score Team Two'));
     $actions = new FieldList(FormAction::create("doAddGame")->setTitle("Add Game"));
     $required = new RequiredFields('ScoreTeamOne', 'ScoreTeamTwo');
     $form = Form::create($this, 'doAddGame', $fields, $actions, $required);
     $form->setTemplate('forms/NewGameForm');
     return $form;
 }
 public function getValueField()
 {
     $fields = array('Boolean' => CheckboxField::create("Value"), 'Number' => NumericField::create("Value"), 'String' => TextField::create("Value"));
     if (isset($fields[$this->ValueType])) {
         return $fields[$this->ValueType];
     } else {
         return new LiteralField("Value", _t('Feature.SAVETOADDVALUE', 'Save record to add value.'));
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.News", NumericField::create("NewsPageLimit")->setTitle(_t("NewsHolder.NewsPageLimit", "Page limit")));
     $NewsGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $NewsArticleGrid = GridField::create("NewsArticles", _t("NewsHolder.NewsArticlesTitle", "News articles"), $this->NewsArticles(), $NewsGridFieldConfig);
     $fields->addFieldToTab("Root.News", $NewsArticleGrid);
     return $fields;
 }
예제 #28
0
 /**
  * @return TextareaField|TextField
  */
 public function getFormField()
 {
     if ($this->getSetting('Rows') && $this->getSetting('Rows') > 1) {
         $taf = new NumericField($this->Name, $this->Title);
         $taf->setRows($this->getSetting('Rows'));
         $taf->addExtraClass('number');
     } else {
         $taf = new NumericField($this->Name, $this->Title, null, $this->getSetting('MaxLength'));
         $taf->addExtraClass('number');
     }
     if ($this->Required) {
         //  Required and numeric validation can conflict so add the Required validation messages
         // as input attributes
         $errorMessage = $this->getErrorMessage()->HTML();
         $taf->setAttribute('data-rule-required', 'true');
         $taf->setAttribute('data-msg-required', $errorMessage);
     }
     return $taf;
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function (FieldList $fields) {
         $fields[] = DropdownField::create('BlogID', _t('BlogCategoriesWidget.Blog', 'Blog'), Blog::get()->map());
         $fields[] = NumericField::create('Limit', _t('BlogCategoriesWidget.Limit.Label', 'Limit'), 0)->setDescription(_t('BlogCategoriesWidget.Limit.Description', 'Limit the number of categories shown by this widget (set to 0 to show all categories).'))->setMaxLength(3);
         $fields[] = DropdownField::create('Order', _t('BlogCategoriesWidget.Sort.Label', 'Sort'), array('Title' => 'Title', 'Created' => 'Created', 'LastUpdated' => 'Updated'))->setDescription(_t('BlogCategoriesWidget.Sort.Description', 'Change the order of categories shown by this widget.'));
         $fields[] = DropdownField::create('Direction', _t('BlogCategoriesWidget.Direction.Label', 'Direction'), array('ASC' => 'Ascending', 'DESC' => 'Descending'))->setDescription(_t('BlogCategoriesWidget.Direction.Description', 'Change the direction of ordering of categories shown by this widget.'));
     });
     return parent::getCMSFields();
 }
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         /**
          * @var FieldList $fields
          */
         $fields->merge(array(DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()), NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts'))));
     });
     return parent::getCMSFields();
 }