mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-02 15:57:53 +02:00
Merge pull request #1728 from wilr/open6445
FIX: Ensure FieldList::push() doesn't eliminate key
This commit is contained in:
commit
77514204ee
@ -402,7 +402,8 @@ class FieldList extends ArrayList {
|
|||||||
public function push($item, $key = null) {
|
public function push($item, $key = null) {
|
||||||
$this->onBeforeInsert($item);
|
$this->onBeforeInsert($item);
|
||||||
$item->setContainerFieldList($this);
|
$item->setContainerFieldList($this);
|
||||||
return parent::push($item, $key = null);
|
|
||||||
|
return parent::push($item, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -410,7 +411,10 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
protected function onBeforeInsert($item) {
|
protected function onBeforeInsert($item) {
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
if($item->getName()) $this->rootFieldList()->removeByName($item->getName(), true);
|
|
||||||
|
if($item->getName()) {
|
||||||
|
$this->rootFieldList()->removeByName($item->getName(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -420,7 +424,10 @@ class FieldList extends ArrayList {
|
|||||||
* @param Form $form The form to set this FieldList to
|
* @param Form $form The form to set this FieldList to
|
||||||
*/
|
*/
|
||||||
public function setForm($form) {
|
public function setForm($form) {
|
||||||
foreach($this as $field) $field->setForm($form);
|
foreach($this as $field) {
|
||||||
|
$field->setForm($form);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user