Example #1
0
 /**
  * @param string    $name
  * @param string    $label
  * @param FormField $field
  * @param bool      $open
  *
  * @return ToggleCompositeField
  */
 protected function getToggleField($name, $label, $field, $open = false)
 {
     $field = new ToggleCompositeField($name, $label, array($field));
     $field->addExtraClass("code-editor-toggle");
     $field->setStartClosed(!$open);
     return $field;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push($manual = new ToggleCompositeField('TextLinks', 'Enter urls', [new TextField('From', 'From url (e.g. "/my-page/")'), new TextField('To', 'To url (e.g. "/my-page/", "http://google.com/")')]));
     $fields->push($page = new ToggleCompositeField('SiteTree', 'Select pages from list', [new TreeDropdownField('FromRelationID', 'From', 'SiteTree'), new TreeDropdownField('ToRelationID', 'To', 'SiteTree')]));
     if ($this->getField('From') || $this->getField('To')) {
         $manual->setStartClosed(false);
     }
     if ($this->getField('FromRelationID') || $this->getField('ToRelationID')) {
         $page->setStartClosed(false);
     }
     return $fields;
 }
 /**
  * Extracts out the field updating since that could happen at a couple
  * different extension points.
  * @param FieldList $fields
  */
 protected function updateFields(FieldList $fields)
 {
     // This seemed to cause problems. Moved to config.yml.
     //Requirements::javascript(SHOP_EXTENDEDPRICING_FOLDER . '/javascript/ExtendedPricingAdmin.js');
     $newFields = array(new CheckboxField("PromoActive", "Promotional pricing active?"), new OptionsetField("PromoDisplay", "Display Settings", array("ShowDiscount" => "Show base price crossed out", "HideDiscount" => "Hide base price")), new OptionsetField("PromoType", "Type of discount", array("Percent" => "Percentage of subtotal (eg 25%)", "Amount" => "Fixed amount (eg \$25.00)")), new PercentageField("PromoPercent", "Percent discount"), new NumericField("PromoAmount", "Fixed discount (e.g. 5 = \$5 off)"), new FieldGroup("Valid date range (optional):", array(PromoDatetimeField::create("PromoStartDate", "Start Date / Time"), PromoDatetimeField::create("PromoEndDate", "End Date / Time (you should set the end time to 23:59:59, if you want to include the entire end day)"))));
     $f = new ToggleCompositeField('PromoFields', 'Promotional Pricing', $newFields);
     $f->setStartClosed(!$this->getOwner()->PromoActive);
     if ($fields->hasTabSet()) {
         $fields->addFieldToTab('Root.Pricing', $f);
     } else {
         $fields->push($f);
     }
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     $from = new TextField('From', 'From');
     $from->setRightTitle('(e.g "/my-page/")- always include the /');
     $to = new TextField('To', 'To');
     $to->setRightTitle('e.g "/my-page/" for internal pages or "http://google.com/" for external websites (and include the scheme - http:// or https://)');
     $fields->push($manual = new ToggleCompositeField('TextLinks', 'Enter urls', [$from, $to]));
     $fields->push($page = new ToggleCompositeField('SiteTree', 'Select pages from list', [new TreeDropdownField('FromRelationID', 'From', 'SiteTree'), new TreeDropdownField('ToRelationID', 'To', 'SiteTree')]));
     $fields->push(new DropdownField('Type', 'Type', ['Vanity' => 'Vanity', 'Permanent' => 'Permanent']));
     if ($this->getField('From') || $this->getField('To')) {
         $manual->setStartClosed(false);
     }
     if ($this->getField('FromRelationID') || $this->getField('ToRelationID')) {
         $page->setStartClosed(false);
     }
     return $fields;
 }