API CHANGE LeftAndMain->EditForm() returns EmptyForm() by default, as not all subclasses might want to implement the previously used getEditForm() method (e.g. ModelAdmin, which has its own sub-controllers to handle requests). Added specialized EditForm() overrides to AssetAdmin and CMSMain

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92759 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 03:17:16 +00:00
parent 59790b102d
commit 23bac6e84f
3 changed files with 31 additions and 21 deletions

View File

@ -279,10 +279,19 @@ HTML;
} }
} }
/**
* @return Form
*/
function EditForm($request = null) {
return $this->getEditForm();
}
/** /**
* Return the form that displays the details of a folder, including a file list and fields for editing the folder name. * Return the form that displays the details of a folder, including a file list and fields for editing the folder name.
*/ */
function getEditForm($id = null) { function getEditForm($id = null) {
if(!$id) $id = $this->currentPageID();
if($id && $id != "root") { if($id && $id != "root") {
$record = DataObject::get_by_id("File", $id); $record = DataObject::get_by_id("File", $id);
} else { } else {

View File

@ -306,6 +306,13 @@ JS;
} }
} }
/**
* @return Form
*/
function EditForm($request = null) {
return $this->getEditForm();
}
/** /**
* Calls {@link SiteTree->getCMSFields()} * Calls {@link SiteTree->getCMSFields()}
*/ */

View File

@ -771,29 +771,23 @@ JS;
} }
/** /**
* Uses {@link getEditForm()} to retrieve an edit form * Retrieves an edit form, either for display, or to process submitted data.
* based on the submitted data. Used for form submissions, * Also used in the template rendered through {@link Right()} in the $EditForm placeholder.
* not for template rendering.
* *
* @param HTTPRequest $request * This is a "pseudo-abstract" methoed, usually connected to a {@link getEditForm()}
* @return Form * method in a concrete subclass. This method can accept a record identifier,
*/ * selected either in custom logic, or through {@link currentPageID()}.
function EditForm($request = null) { * The form usually construct itself from {@link DataObject->getCMSFields()}
return $this->getEditForm($request ? $request->requestVar('ID') : null); * for the specific managed subclass defined in {@link LeftAndMain::$tree_class}.
}
/**
* Gets the edit form of a specific record. Will usually construct itself
* from {@link DataObject->getCMSFields()} for the specific managed subclass
* defined in {@link LeftAndMain::$tree_class}.
* *
* @param int $id ID of a record for {@link LeftAndMain::$tree_class} (Optional) * @param HTTPRequest $request Optionally contains an identifier for the
* record to load into the form.
* @return Form Should return a form regardless wether a record has been found. * @return Form Should return a form regardless wether a record has been found.
* Form might be readonly if the current user doesn't have the permission to edit * Form might be readonly if the current user doesn't have the permission to edit
* the record. * the record.
*/ */
function getEditForm($id = null) { function EditForm($request = null) {
die('getEditForm(): Not implemented'); return $this->EmptyForm();
} }
/** /**
@ -839,9 +833,9 @@ JS;
} }
public function printable() { public function printable() {
$id = $_REQUEST['ID'] ? $_REQUEST['ID'] : $this->currentPageID(); $form = $this->getEditForm($this->currentPageID());
if(!$form) return false;
if($id) $form = $this->getEditForm($id);
$form->transform(new PrintableTransformation()); $form->transform(new PrintableTransformation());
$form->actions = null; $form->actions = null;