/**
  * updateCMSFields
  *
  * @return $fields
  */
 public function updateCMSFields(Fieldlist $fields)
 {
     if ($this->owner->ShowCarousel) {
         $carousel_table = GridField::create('CarouselElements', false, $this->owner->CarouselElements()->sort('Sort ASC'), GridFieldConfig_RecordEditor::create());
         $fields->addFieldToTab('Root.Carousel', $carousel_table);
     } else {
         $fields->removeByName('CarouselElements');
     }
     $fields->removeByName('ShowCarousel');
     return $fields;
 }
 public function updateCMSFields(Fieldlist $fields)
 {
     // If Users Requests Carousel On Page
     if ($this->owner->ShowCarousel) {
         // Create Add Image Button
         $add_button = new GridFieldAddNewButton('toolbar-header-left');
         $add_button->setButtonName(_t('CarouselPage.ADDIMAGE', 'Add Image'));
         // Add Carousel Editor
         $grid_config = GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldFilterHeader')->addComponent($add_button);
         // Table to Display Current Carousel Images
         $carousel_table = GridField::create('CarouselElements', false, $this->owner->CarouselElements()->sort('Sort ASC'), $grid_config);
         // Creates a tab on CMS to manage Carousel on
         $fields->addFieldToTab('Root.' . _t('CarouselPage.CAROUSELTABLABEL', 'Carousel'), $carousel_table);
     } else {
         $fields->removeByName('CarouselElements');
     }
     // By default carousel settings do not appear
     $fields->removeByName('ShowCarousel');
     $fields->removeByName('CarouselWidth');
     $fields->removeByName('CarouselHeight');
     parent::updateCMSFields($fields);
 }