Created
July 31, 2015 01:37
-
-
Save stevie-mayhew/00b5472dc508daf72c15 to your computer and use it in GitHub Desktop.
SilverStripe Code Competition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class CatalogPageAdmin - Code submitted by stevie-mayhew | |
*/ | |
class CatalogPageAdmin extends ModelAdmin { | |
/** | |
* @config | |
* @var string | |
*/ | |
private static $menu_icon = 'silverstripe-catalogmanager/images/catalog.png'; | |
/** | |
* Initialize requirements for this view | |
*/ | |
public function init() { | |
parent::init(); | |
Requirements::javascript(CMS_DIR . '/javascript/CMSMain.EditForm.js'); | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function getEditForm($id = null, $fields = null) { | |
$model = singleton($this->modelClass); | |
$list = $this->getList()->setDataQueryParam(array( | |
'Versioned.stage' => 'Stage' | |
)); | |
$listField = GridField::create( | |
$this->sanitiseClassName($this->modelClass), | |
false, | |
$list, | |
$fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length')) | |
->removeComponentsByType('GridFieldFilterHeader') | |
->addComponent(new GridfieldPagePublishAction()) | |
); | |
return $form = CMSForm::create( | |
$this, | |
'EditForm', | |
new FieldList($listField), | |
new FieldList() | |
)->setHTMLID('Form_EditForm'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment