Beispiel #1
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldsFromTab('Root.Main', array('Image', 'Caption', 'Link', 'Anchor'));
     $fields->addFieldsToTab('Root.Main', array(new UploadField('Image'), new TextField('CaptionLarge', 'Large Caption (large text at top)'), new TextareaField('CaptionSmall', 'Large Caption (smaller text underneath)'), new WTLinkField('Link', 'Link (optional)')));
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->stat('box_limit')) {
         $fields->insertAfter(new Tab('PromoBoxes'), 'Main');
         //content boxes
         $boxes = PromoBox::get();
         $aBoxes = $this->PromoBoxes()->toArray();
         $dropBoxes = $boxes->map();
         for ($i = 0; $i < $this->stat('box_limit'); $i++) {
             $value = !empty($aBoxes[$i]) ? $aBoxes[$i]->ID : null;
             $fields->addFieldToTab('Root.PromoBoxes', new DropdownField("PromoBoxes[{$i}]", 'Promo Box ' . ($i + 1), $dropBoxes, $value, null, 'No Box'));
         }
     }
 }