diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 4b5f8bf3d91..c7bb0eabfb6 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -222,6 +222,9 @@ public function insertBefore($insertBefore, $field) { return $ret; } + /** + * @uses FieldList->insertAfter() + */ public function insertAfter($insertAfter, $field) { $ret = $this->children->insertAfter($insertAfter, $field); $this->sequentialSet = null; diff --git a/forms/FieldList.php b/forms/FieldList.php index 55188ece342..4f27a11eaf3 100644 --- a/forms/FieldList.php +++ b/forms/FieldList.php @@ -312,7 +312,7 @@ public function findOrMakeTab($tabName, $title = null) { * Returns a named field. * You can use dot syntax to get fields from child composite fields * - * @todo Implement similiarly to dataFieldByName() to support nested sets - or merge with dataFields() + * @todo Implement similarly to dataFieldByName() to support nested sets - or merge with dataFields() */ public function fieldByName($name) { $name = $this->rewriteTabPath($name); @@ -356,6 +356,7 @@ public function dataFieldByName($name) { * * @param string $name Name of the field to insert before * @param FormField $item The form field to insert + * @return FormField|false */ public function insertBefore($name, $item) { // Backwards compatibility for order of arguments @@ -385,6 +386,7 @@ public function insertBefore($name, $item) { * * @param string $name Name of the field to insert after * @param FormField $item The form field to insert + * @return FormField|false */ public function insertAfter($name, $item) { // Backwards compatibility for order of arguments diff --git a/forms/TabSet.php b/forms/TabSet.php index a551830dda4..44b4a50fcbe 100644 --- a/forms/TabSet.php +++ b/forms/TabSet.php @@ -114,7 +114,10 @@ public function getAttributes() { } /** - * Returns the named tab + * Returns a named field. + * + * @param string $name Name of the field you want to find. Allows for dot notation. + * @return FormField|null */ public function fieldByName($name) { if(strpos($name,'.') !== false) list($name, $remainder) = explode('.',$name,2); @@ -135,6 +138,8 @@ public function fieldByName($name) { } } } + + return null; } /** @@ -148,22 +153,24 @@ public function push(FormField $field) { /** * Inserts a field before a particular field in a FieldList. * - * @param FormField $item The form field to insert - * @param string $name Name of the field to insert before + * @param string $insertBefore Name of the field to insert before + * @param FormField $field The form field to insert + * @return FormField|null */ public function insertBefore($insertBefore, $field) { - parent::insertBefore($insertBefore, $field); if($field instanceof Tab) $field->setTabSet($this); - $this->sequentialSet = null; + return parent::insertBefore($insertBefore, $field); } + /** + * Inserts a field after a particular field in a FieldList. + * + * @param string $insertAfter Name of the field to insert after + * @param FormField $field The form field to insert + * @return FormField|null + */ public function insertAfter($insertAfter, $field) { - parent::insertAfter($insertAfter, $field); if($field instanceof Tab) $field->setTabSet($this); - $this->sequentialSet = null; - } - - public function removeByName( $tabName, $dataFieldOnly = false ) { - parent::removeByName( $tabName, $dataFieldOnly ); + return parent::insertAfter($insertAfter, $field); } }