Permalink
Browse files

FIX: Ensure FieldList::push() doesn't eliminate key

  • Loading branch information...
wilr committed Apr 6, 2013
1 parent b25eda8 commit 69722222b4af13b72c597041e6933851441f76b7
Showing with 10 additions and 3 deletions.
  1. +10 −3 forms/FieldList.php
View
@@ -402,15 +402,19 @@ public function insertAfter($item, $name) {
public function push($item, $key = null) {
$this->onBeforeInsert($item);
$item->setContainerFieldList($this);
- return parent::push($item, $key = null);
+
+ return parent::push($item, $key);
}
/**
* Handler method called before the FieldList is going to be manipulated.
*/
protected function onBeforeInsert($item) {
$this->flushFieldsCache();
- if($item->getName()) $this->rootFieldList()->removeByName($item->getName(), true);
+
+ if($item->getName()) {
+ $this->rootFieldList()->removeByName($item->getName(), true);
+ }
}
@@ -420,7 +424,10 @@ protected function onBeforeInsert($item) {
* @param Form $form The form to set this FieldList to
*/
public function setForm($form) {
- foreach($this as $field) $field->setForm($form);
+ foreach($this as $field) {
+ $field->setForm($form);
+ }
+
return $this;
}

0 comments on commit 6972222

Please sign in to comment.