Sha256: 6430db0a4011fc3d4d0181b2639b940ca01c98d6ceafd99b5eae0dc7971402b3

Contents?: true

Size: 1.79 KB

Versions: 11

Compression:

Stored size: 1.79 KB

Contents

<?php

/**
 * AddModelAdmin is an extension of ModelAdmin designed to allow some customisation to the edit form etc.
 * 
 * @author AzT3k
 */
class AbcModelAdmin extends ModelAdmin {
	
	/**
	 * This method generates the list view form
	 * Individual items are handled by the gridfielddetailform - this is is defined in GridFieldDetailForm_ItemRequest::ItemEditForm() and has been overloaded in the subclass
	 * 
	 * @param type $id
	 * @param type $fields
	 * @return \AbcModelAdminForm
	 */
	function getEditForm($id = null, $fields = null) {
				
		$list = $this->getList();
		$exportButton = new GridFieldExportButton('before');
		$exportButton->setExportColumns($this->getExportFields());
		$listField = GridField::create(
			$this->sanitiseClassName($this->modelClass),
			false,
			$list,
			$fieldConfig = AddGridFieldConfig_RecordEditor::create($this->stat('page_length'))
				->addComponent($exportButton)
				->removeComponentsByType('GridFieldFilterHeader')
				->addComponents(new GridFieldPrintButton('before'))
		);

		// Validation
		if(singleton($this->modelClass)->hasMethod('getCMSValidator')) {
			$detailValidator = singleton($this->modelClass)->getCMSValidator();
			$listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator);
		}

		$form = new AbcModelAdminForm(
			$this,
			'EditForm',
			new FieldList($listField),
			new FieldList
		);
		$form->addExtraClass('cms-edit-form cms-panel-padded center');
		$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
		$form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm'));
		$form->setAttribute('data-pjax-fragment', 'CurrentForm');

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bonethug-0.0.17 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.16 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.15 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.14 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.13 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.12 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.11 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.10 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.7 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.6 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php
bonethug-0.0.5 skel/project_types/silverstripe3/public/abc/code/Admin/AbcModelAdmin.php