Fixed bugs with #1403 changes made in r62218.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62268 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-09-11 06:24:40 +00:00
parent c9f5e1ef58
commit 5393392c48
2 changed files with 5 additions and 4 deletions

View File

@ -149,16 +149,13 @@ class CompositeField extends FormField {
* Add a new child field to the end of the set. * Add a new child field to the end of the set.
*/ */
public function push(FormField $field) { public function push(FormField $field) {
//$this->rootFieldSet()->removeByName($field->Name());
$this->children->push($field); $this->children->push($field);
} }
public function insertBefore($field, $insertBefore) { public function insertBefore($field, $insertBefore) {
//$this->rootFieldSet()->removeByName($field->Name());
return $this->children->insertBefore($field, $insertBefore); return $this->children->insertBefore($field, $insertBefore);
} }
public function insertBeforeRecursive($field, $insertBefore, $level = 0) { public function insertBeforeRecursive($field, $insertBefore, $level = 0) {
//$this->rootFieldSet()->removeByName($field->Name());
return $this->children->insertBeforeRecursive($field, $insertBefore, $level+1); return $this->children->insertBeforeRecursive($field, $insertBefore, $level+1);
} }
public function removeByName($fieldName) { public function removeByName($fieldName) {
@ -169,6 +166,11 @@ class CompositeField extends FormField {
return $this->children->replaceField($fieldName, $newField); return $this->children->replaceField($fieldName, $newField);
} }
function rootFieldSet() {
if(is_object($this->containerFieldSet)) return $this->containerFieldSet->rootFieldSet();
else return $this->children;
}
/** /**
* Return a readonly version of this field. Keeps the composition but returns readonly * Return a readonly version of this field. Keeps the composition but returns readonly
* versions of all the children * versions of all the children

View File

@ -531,7 +531,6 @@ HTML;
} }
function rootFieldSet() { function rootFieldSet() {
return $this->containerFieldSet->rootFieldSet();
if(is_object($this->containerFieldSet)) return $this->containerFieldSet->rootFieldSet(); if(is_object($this->containerFieldSet)) return $this->containerFieldSet->rootFieldSet();
else user_error("rootFieldSet() called on $this->class object without a containerFieldSet", E_USER_ERROR); else user_error("rootFieldSet() called on $this->class object without a containerFieldSet", E_USER_ERROR);
} }