Skip to content

Commit

Permalink
updated the bug fix after discussion with Akrabat and Bakura in irc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Hedgecock committed Jul 9, 2012
1 parent 6dfc2e8 commit 5a5df38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions library/Zend/Form/Element/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ public function setOptions($options)
*/
public function populateValues($data)
{
if (!is_array($data) && !$data instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an array or Traversable set of data; received "%s"',
__METHOD__,
(is_object($data) ? get_class($data) : gettype($data))
));
}

// Can't do anything with empty data
if (empty($data)) {

return;
}

if ($this->targetElement instanceof FieldsetInterface) {
foreach ($this->byName as $name => $fieldset) {
$fieldset->populateValues($data[$name]);
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Form/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function populateValues($data)

$element = $this->get($name);

if ($element instanceof FieldsetInterface && is_array($value) && !empty($value)) {
if ($element instanceof FieldsetInterface && is_array($value)) {
$element->populateValues($value);
continue;
}
Expand Down

0 comments on commit 5a5df38

Please sign in to comment.