Jump to:

5451 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » DataObjectDecorator adding fields to tabs

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 714 Views
  • DanStephenson
    Avatar
    Community Member
    115 Posts

    DataObjectDecorator adding fields to tabs Link to this post

    Hello,

    I am trying to Decorate the EventCalendar module. I've created the following class:

    <?php
    class CustomCalendarEvent extends DataObjectDecorator {
    function extraStatics() {
    return array(
    'db' => array(
              'Location' => 'Text',
              'ShortDesc' => 'Text',
              'MarketingMessage' => 'Text',
    ),
    'has_one' => array(
              'FullImage' => 'Image',
              'Thumb' => 'Image'
    ),
    );
    }
       
       public function getCMSFields() {
          $this->extend('updateCMSFields', $fields);
          return $fields;
       }
       
       public function updateCMSFields(FieldSet $fields) {
          $fields->push(new TextField('Location', 'Event Location'));
          $fields->push(new TextField('ShortDesc', 'Short Description'));
          $fields->push(new TextField('MarketingMessage', 'Marketing Message'));
          $fields->push(new ImageField('FullImage', 'Full Image'));
          $fields->push(new ImageField('Thumb', 'Thumbnail Image'));
       }
    }

    How can I make the new fields show up inside the CMS fields - such as Content.Main or a new Content.Images?

  • netnerd85
    Avatar
    Community Member
    42 Posts

    Re: DataObjectDecorator adding fields to tabs Link to this post

    Try the following:

    public function updateCMSFields(FieldSet &$fields) {
       $fields->addFieldToTab('Root.Content.Main', new TextField('Location', 'Event Location'));
    }

    or

    public function updateCMSFields(FieldSet &$fields) {
       $fields->addFieldToTab('Root.Main', new TextField('Location', 'Event Location'));
    }

    714 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.