From 4541dbb04e1429af314d9c6c3426571a85856b05 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 3 Oct 2008 16:33:37 +0000 Subject: [PATCH] ENHANCEMENT Removed overloaded MemberTableField->DetailForm() and reduced overloaded constructor logic - same behaviour found in parent classes git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@63626 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/MemberTableField.php | 71 +-------------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/code/MemberTableField.php b/code/MemberTableField.php index dc9321ea..1db481b5 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -89,30 +89,6 @@ class MemberTableField extends ComplexTableField { if(!$hidePassword) { $fieldList["SetPassword"] = "Password"; } - - if(isset($_REQUEST['ctf']['childID']) && $memberID = $_REQUEST['ctf']['childID']) { - $SNG_member = DataObject::get_by_id($this->stat("data_class"),$memberID); - } else { - $SNG_member = singleton(Object::getCustomClass($this->stat("data_class"))); - } - - // If the fieldset is passed, use it, else use the formfields returned - // from the object via a string method call. - if(is_a($this->detailFormFields,"Fieldset")){ - $detailFormFields = $this->detailFormFields; - } else if(is_string($this->detailFormFields)){ - $functioncall = $this->detailFormFields; - if($SNG_member->hasMethod($functioncall)){ - $detailFields = $childData->$functioncall(); - } - } else { - $detailFormFields = $SNG_member->getCMSFields(); - } - - - $this->detailFormValidator = $SNG_member->getValidator(); - - $this->pageSize = $pageLimit; // Legacy: Use setCustomSourceItems() instead. if($members) { @@ -121,7 +97,7 @@ class MemberTableField extends ComplexTableField { $this->hidePassword = $hidePassword; - parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields); + parent::__construct($controller, $name, $sourceClass, $fieldList); Requirements::javascript(CMS_DIR . '/javascript/MemberTableField.js'); Requirements::javascript(CMS_DIR . "/javascript/MemberTableField_popup.js"); @@ -168,51 +144,6 @@ class MemberTableField extends ComplexTableField { return "{$this->Link()}&methodName=add"; } - /** - * TODO Check if this was modified as a result of the - * Ajax changes. As a single method, it should be fairly safe - */ - function DetailForm() { - $ID = Convert::raw2xml(isset($_REQUEST['ctf']['ID']) - ? $_REQUEST['ctf']['ID'] - : ''); - $childID = isset($_REQUEST['ctf']['childID']) ? Convert::raw2xml($_REQUEST['ctf']['childID']) : 0; - $childClass = Convert::raw2xml($_REQUEST['fieldName']); - $methodName = isset($_REQUEST['methodName']) ? $_REQUEST['methodName'] : ''; - - if($methodName == "add") { - $parentIdName = $this->getParentIdName($childClass,$this->getParentClass()); - if(!$parentIdName) { - user_error("ComplexTableField::DetailForm() Dataobject does not seem to have an 'has-one'-relationship", E_USER_WARNING); - return; - } - $this->detailFormFields->push(new HiddenField('parentClass'," ",$this->getParentClass())); - } - - // the ID field confuses the Controller-logic in finding the right view for ReferencedField - $this->detailFormFields->removeByName('ID'); - - $this->detailFormFields->push(new HiddenField("ctf[ID]"," ",$ID)); - // add a namespaced ID instead thats "converted" by saveComplexTableField() - $this->detailFormFields->push(new HiddenField("ctf[childID]","",$childID)); - $this->detailFormFields->push(new HiddenField("ClassName","",$this->sourceClass)); - - $form = Object::create('MemberTableField_Popup', $this, "DetailForm", $this->detailFormFields, $this->sourceClass, $methodName == "show", $this->detailFormValidator); - - if (is_numeric($childID)) { - if ($methodName == "show" || $methodName == "edit") { - $childData = DataObject::get_by_id($this->sourceClass, $childID); - $form->loadDataFrom($childData); - } - } - - if ($methodName == "show") { - $form->makeReadonly(); - } - - return $form; - } - function SearchForm() { $searchFields = new FieldGroup( new TextField('MemberSearch', _t('MemberTableField.SEARCH', 'Search')),