function updateCMSFields(FieldList $fields)
 {
     //prevent certain pages from having a Document tab in the CMS
     if (in_array($this->owner->ClassName, self::$noDocumentsList)) {
         return;
     }
     //javascript to customize the grid field for the DMS document (overriding entwine in FRAMEWORK_DIR.'/javascript/GridField.js'
     Requirements::javascript(DMS_DIR . '/javascript/DMSGridField.js');
     Requirements::css(DMS_DIR . '/css/DMSMainCMS.css');
     //javascript for the link editor pop-up in TinyMCE
     Requirements::javascript(DMS_DIR . "/javascript/DocumentHtmlEditorFieldToolbar.js");
     // Document listing
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldEditButton(), new DMSGridFieldDeleteAction(), new GridFieldDetailForm());
     if (class_exists('GridFieldPaginatorWithShowAll')) {
         $paginatorComponent = new GridFieldPaginatorWithShowAll(15);
     } else {
         $paginatorComponent = new GridFieldPaginator(15);
     }
     $gridFieldConfig->addComponent($paginatorComponent);
     if (class_exists('GridFieldSortableRows')) {
         $sortableComponent = new GridFieldSortableRows('DocumentSort');
         $sortableComponent->setUsePagination(false)->setForceRedraw(true);
         $gridFieldConfig->addComponent($sortableComponent);
     }
     // HACK: Create a singleton of DMSDocument to ensure extensions are applied before we try to get display fields.
     singleton('DMSDocument');
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(Config::inst()->get('DMSDocument', 'display_fields'))->setFieldCasting(array('LastChanged' => "Datetime->Ago"))->setFieldFormatting(array('FilenameWithoutID' => '<a target=\'_blank\' class=\'file-url\' href=\'$Link\'>$FilenameWithoutID</a>'));
     //override delete functionality with this class
     $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('DMSGridFieldDetailForm_ItemRequest');
     $gridField = GridField::create('Documents', false, $this->owner->Documents()->Sort('DocumentSort'), $gridFieldConfig);
     $gridField->addExtraClass('documents');
     $uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="add" href="%s">%s</a>', Controller::join_links(singleton('DMSDocumentAddController')->Link(), '?ID=' . $this->owner->ID), "Add Documents"));
     $fields->addFieldsToTab('Root.Documents (' . $this->owner->Documents()->Count() . ')', array($uploadBtn, $gridField));
 }