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
This commit is contained in:
Ingo Schommer 2008-10-03 16:33:37 +00:00
parent 926949e9cc
commit 4541dbb04e

View File

@ -90,30 +90,6 @@ class MemberTableField extends ComplexTableField {
$fieldList["SetPassword"] = "Password"; $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. // Legacy: Use setCustomSourceItems() instead.
if($members) { if($members) {
$this->customSourceItems = $this->memberListWithGroupID($members, $group); $this->customSourceItems = $this->memberListWithGroupID($members, $group);
@ -121,7 +97,7 @@ class MemberTableField extends ComplexTableField {
$this->hidePassword = $hidePassword; $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.js');
Requirements::javascript(CMS_DIR . "/javascript/MemberTableField_popup.js"); Requirements::javascript(CMS_DIR . "/javascript/MemberTableField_popup.js");
@ -168,51 +144,6 @@ class MemberTableField extends ComplexTableField {
return "{$this->Link()}&methodName=add"; 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() { function SearchForm() {
$searchFields = new FieldGroup( $searchFields = new FieldGroup(
new TextField('MemberSearch', _t('MemberTableField.SEARCH', 'Search')), new TextField('MemberSearch', _t('MemberTableField.SEARCH', 'Search')),