src/ArchiveAdmin.php
public function getEditForm($id = null, $fields = null)
    {
        $fields = FieldList::create();
        $modelClass = $this->request->getVar('others') ? 'others' : $this->modelClass;
        $classInst = Injector::inst()->get($this->modelClass);

        if (ClassInfo::hasMethod($classInst, 'getArchiveField')) {
            $listField = $classInst->getArchiveField();
            $fields->push($listField);
        } else {
            $otherVersionedObjects = $this->getVersionedModels('other');
            $modelSelectField = $this->getOtherModelSelectorField($modelClass);
            $fields->push($modelSelectField);

            // If a valid other model name is passed via a request param
            // then show a gridfield with archived records
            if (array_search($modelClass, $otherVersionedObjects)) {
                $listField = $this->createArchiveGridField('Others', $modelClass);

                $listColumns = $listField->getConfig()->getComponentByType(GridFieldDataColumns::class);
                $listColumns->setDisplayFields([
                    'Title' => _t(__CLASS__ . '.COLUMN_TITLE', 'Title'),
                    'Versions.first.LastEdited' => _t(__CLASS__ . '.COLUMN_DATEARCHIVED', 'Date Archived'),
                    'Versions.first.Author.Name' => _t(__CLASS__ . '.COLUMN_ARCHIVEDBY', 'Archived By'),
                ]);
                $listColumns->setFieldFormatting([
                    'Versions.first.LastEdited' => function ($val, $item) {
                        return DBDatetime::create_field('Datetime', $val)->Ago();
                    },
                ]);

                $fields->push($listField);
            }
        }

        $form = Form::create(
            $this,
            'EditForm',
            $fields,
            FieldList::create()
        )->setHTMLID('Form_EditForm');
        $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
        $form->setAttribute('data-pjax-fragment', 'CurrentForm');
        $form->addExtraClass(
            'ArchiveAdmin discardchanges cms-edit-form cms-panel-padded center flexbox-area-grow '.
            $this->BaseCSSClasses()
        );
        $form->setFormAction(Controller::join_links(
            $this->Link($this->sanitiseClassName($this->modelClass)),
            'EditForm'
        ));

        $this->extend('updateEditForm', $form);

        return $form;
    }
public function getEditForm($id = null, $fields = null)
    {
        $fields = FieldList::create();
        $modelClass = $this->request->getVar('others') ? 'others' : $this->modelClass;
        $classInst = Injector::inst()->get($this->modelClass);

        if (ClassInfo::hasMethod($classInst, 'getArchiveField')) {
            $listField = $classInst->getArchiveField();
            $fields->push($listField);
        } else {
            $otherVersionedObjects = $this->getVersionedModels('other');
            $modelSelectField = $this->getOtherModelSelectorField($modelClass);
            $fields->push($modelSelectField);

            // If a valid other model name is passed via a request param
            // then show a gridfield with archived records
            if (array_search($modelClass, $otherVersionedObjects)) {
                $listField = $this->createArchiveGridField('Others', $modelClass);

                $listColumns = $listField->getConfig()->getComponentByType(GridFieldDataColumns::class);
                $listColumns->setDisplayFields([
                    'Title' => _t(__CLASS__ . '.COLUMN_TITLE', 'Title'),
                    'Versions.first.LastEdited' => _t(__CLASS__ . '.COLUMN_DATEARCHIVED', 'Date Archived'),
                    'Versions.first.Author.Name' => _t(__CLASS__ . '.COLUMN_ARCHIVEDBY', 'Archived By'),
                ]);
                $listColumns->setFieldFormatting([
                    'Versions.first.LastEdited' => function ($val, $item) {
                        return DBDatetime::create_field('Datetime', $val)->Ago();
                    },
                ]);

                $fields->push($listField);
            }
        }

        $form = Form::create(
            $this,
            'EditForm',
            $fields,
            FieldList::create()
        )->setHTMLID('Form_EditForm');
        $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
        $form->setAttribute('data-pjax-fragment', 'CurrentForm');
        $form->addExtraClass(
            'ArchiveAdmin discardchanges cms-edit-form cms-panel-padded center flexbox-area-grow '.
            $this->BaseCSSClasses()
        );
        $form->setFormAction(Controller::join_links(
            $this->Link($this->sanitiseClassName($this->modelClass)),
            'EditForm'
        ));

        $this->extend('updateEditForm', $form);

        return $form;
    }
public function getEditForm ( $ id = null , $ fields = null ) { $ fields = FieldList :: create ( ) ; $ modelClass = $ this -> request -> getVar ( 'others' ) ? 'others' : $ this -> modelClass ; $ classInst = Injector :: inst ( ) -> get ( $ this -> modelClass ) ; if ( ClassInfo :: hasMethod ( $ classInst , 'getArchiveField' ) ) { $ listField = $ classInst -> getArchiveField ( ) ; $ fields -> push ( $ listField ) ; } else { $ otherVersionedObjects = $ this -> getVersionedModels ( 'other' ) ; $ modelSelectField = $ this -> getOtherModelSelectorField ( $ modelClass ) ; $ fields -> push ( $ modelSelectField ) ; // If a valid other model name is passed via a request param // then show a gridfield with archived records if ( array_search ( $ modelClass , $ otherVersionedObjects ) ) { $ listField = $ this -> createArchiveGridField ( 'Others' , $ modelClass ) ; $ listColumns = $ listField -> getConfig ( ) -> getComponentByType ( GridFieldDataColumns :: class ) ; $ listColumns -> setDisplayFields ( [ 'Title' => _t ( __CLASS__ . '.COLUMN_TITLE' , 'Title' ) , 'Versions.first.LastEdited' => _t ( __CLASS__ . '.COLUMN_DATEARCHIVED' , 'Date Archived' ) , 'Versions.first.Author.Name' => _t ( __CLASS__ . '.COLUMN_ARCHIVEDBY' , 'Archived By' ) , ] ) ; $ listColumns -> setFieldFormatting ( [ 'Versions.first.LastEdited' => function ( $ val , $ item ) { return DBDatetime :: create_field ( 'Datetime' , $ val ) -> Ago ( ) ; } , ] ) ; $ fields -> push ( $ listField ) ; } } $ form = Form :: create ( $ this , 'EditForm' , $ fields , FieldList :: create ( ) ) -> setHTMLID ( 'Form_EditForm' ) ; $ form -> setTemplate ( $ this -> getTemplatesWithSuffix ( '_EditForm' ) ) ; $ form -> setAttribute ( 'data-pjax-fragment' , 'CurrentForm' ) ; $ form -> addExtraClass ( 'ArchiveAdmin discardchanges cms-edit-form cms-panel-padded center flexbox-area-grow ' . $ this -> BaseCSSClasses ( ) ) ; $ form -> setFormAction ( Controller :: join_links ( $ this -> Link ( $ this -> sanitiseClassName ( $ this -> modelClass ) ) , 'EditForm' ) ) ; $ this -> extend ( 'updateEditForm' , $ form ) ; return $ form ; }
Produces an edit form with relevant prioritised tabs for Pages, Blocks and Files

@param int|null $id
@param FieldList|null $fields
@return Form A Form object with one tab per {@link \SilverStripe\Forms\GridField\GridField}
Produces an edit form with relevant prioritised tabs for Pages Blocks and Files