public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $grid = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass)); $grid->getConfig()->removeComponentsByType('GridFieldPaginator')->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldPrintButton')->removeComponentsByType('GridFieldExportButton')->removeComponentsByType('GridFieldDetailForm')->addComponents(new VersionedForm(), new GridFieldPaginatorWithShowAll(30), $multiClass = new MultiClassSelector(), $sortable = new GridFieldOrderableRows('SortOrder')); $subBlocks = self::getAvaiableTypes(); $multiClass->setClasses($subBlocks); $grid->setTitle('All Blcoks'); return $form; }
private function gridBuilder($name, $source, $label = '', $canAdd = false, $gridHeaderType = 'GridFieldConfig_RecordEditor') { /* GridFieldConfig_Base GridFieldConfig_RecordViewer GridFieldConfig_RecordEditor GridFieldConfig_RelationEditor */ if ($label == '') { $label = $name; } $grid = new GridField($name, $label, $source); $config = $gridHeaderType::create(); $config->removeComponentsByType('GridFieldAddNewButton'); if ($canAdd) { $config->removeComponentsByType('GridFieldPaginator')->removeComponentsByType('GridFieldDetailForm')->addComponents(new VersionedForm(), new GridFieldPaginatorWithShowAll(30), $multiClass = new MultiClassSelector(), $sortable = new OrderableBlocks('SortOrder')); $subBlocks = BlocksAdmin::getAvaiableTypes(); $multiClass->setClasses($subBlocks); } $grid->setConfig($config); return $grid; }