diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 829e7e903..62d751a34 100755 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -149,16 +149,13 @@ class CompositeField extends FormField { * Add a new child field to the end of the set. */ public function push(FormField $field) { - //$this->rootFieldSet()->removeByName($field->Name()); $this->children->push($field); } public function insertBefore($field, $insertBefore) { - //$this->rootFieldSet()->removeByName($field->Name()); return $this->children->insertBefore($field, $insertBefore); } public function insertBeforeRecursive($field, $insertBefore, $level = 0) { - //$this->rootFieldSet()->removeByName($field->Name()); return $this->children->insertBeforeRecursive($field, $insertBefore, $level+1); } public function removeByName($fieldName) { @@ -168,6 +165,11 @@ class CompositeField extends FormField { public function 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 diff --git a/forms/FormField.php b/forms/FormField.php index 3bfe38846..cc2502a55 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -531,7 +531,6 @@ HTML; } function rootFieldSet() { - 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); }