Skip to content

Commit

Permalink
Fix: re-index array
Browse files Browse the repository at this point in the history
NodeIterator breaks if array is not re-indexed.
  • Loading branch information
Trainmaster committed Sep 21, 2014
1 parent 4fd86bc commit f6eb155
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Vision/DataStructures/Tree/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public function removeChild(NodeInterface $child)
if ($key !== false) {
unset($this->children[$key]);
}

$this->children = array_values($this->children);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Vision/Form/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ public function hasChildren()
public function removeChild(NodeInterface $node)
{
$key = array_search($node, $this->elements, true);

if ($key !== false) {
unset($this->elements[$key]);
}

$this->elements = array_values($this->elements);
}

/**
Expand Down

0 comments on commit f6eb155

Please sign in to comment.