From 27fd6937a59e7af352e42ef9e1cb9378fbd5740c Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 18 Aug 2008 00:52:15 +0000 Subject: [PATCH] Updated AssetTableField to work with ComplexTableField updates git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@60913 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/AssetTableField.php | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/code/AssetTableField.php b/code/AssetTableField.php index 3cad6ef5..aa14fecb 100755 --- a/code/AssetTableField.php +++ b/code/AssetTableField.php @@ -17,8 +17,8 @@ class AssetTableField extends ComplexTableField { //"export", ); function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") { - parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin); + $this-> $this->sourceSort = "Title"; $this->Markable = true; @@ -39,21 +39,10 @@ class AssetTableField extends ComplexTableField { if($this->folder) return $this->folder->ID; } - function DetailForm() { - $ID = (isset($_REQUEST['ctf']['ID'])) ? Convert::raw2xml($_REQUEST['ctf']['ID']) : null; - $childID = (isset($_REQUEST['ctf']['childID'])) ? Convert::raw2xml($_REQUEST['ctf']['childID']) : null; - $childClass = (isset($_REQUEST['fieldName'])) ? Convert::raw2xml($_REQUEST['fieldName']) : null; - $methodName = (isset($_REQUEST['methodName'])) ? $_REQUEST['methodName'] : null; - - if(!$childID) { - user_error("AssetTableField::DetailForm Please specify a valid ID"); - return null; - } - - if($childID) { - $childData = DataObject::get_by_id("File", $childID); - } - + /** + * Get the pop-up fields for the given record. + */ + function getCustomFieldsFor($childData) { if(!$childData) { user_error("AssetTableField::DetailForm No record found"); return null; @@ -151,24 +140,8 @@ class AssetTableField extends ComplexTableField { // the ID field confuses the Controller-logic in finding the right view for ReferencedField $detailFormFields->removeByName('ID'); - // add a namespaced ID instead thats "converted" by saveComplexTableField() - $detailFormFields->push(new HiddenField("ctf[childID]","",$childID)); - $detailFormFields->push(new HiddenField("ctf[ClassName]","",$this->sourceClass)); - - $readonly = ($this->methodName == "show"); - $form = new ComplexTableField_Popup($this, "DetailForm", $detailFormFields, $this->sourceClass, $readonly); - - if (is_numeric($childID)) { - if ($methodName == "show" || $methodName == "edit") { - $form->loadDataFrom($childData); - } - } - if( !$folder->userCanEdit() || $methodName == "show") { - $form->makeReadonly(); - } - - return $form; + return $detailFormFields; } }