Permalink
Browse files

Merge remote-tracking branch 'macnibblet/macnibblet/hotfix/form-field…

…set'
  • Loading branch information...
2 parents 402074c + 5a5df38 commit bc59012097c755d8273247f758bb7fb71be484b8 @akrabat committed Jul 9, 2012
Showing with 20 additions and 0 deletions.
  1. +14 −0 library/Zend/Form/Element/Collection.php
  2. +6 −0 tests/Zend/Form/FieldsetTest.php
@@ -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]);
@@ -98,6 +98,12 @@ public function getMessages()
);
}
+ public function testExtractOnAnEmptyRelationship()
+ {
+ $form = new TestAsset\FormCollection();
+ $form->populateValues(array('fieldsets' => array()));
+ }
+
public function testFieldsetIsEmptyByDefault()
{
$this->assertEquals(0, count($this->fieldset));

0 comments on commit bc59012

Please sign in to comment.