Browse Source

ZF-10491: Applying patch from Richard Tuin

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23412 44c647ce-9c0f-0410-b52a-842ac1e357ba
bittarman 15 years ago
parent
commit
8558374cf8
2 changed files with 13 additions and 0 deletions
  1. 4 0
      library/Zend/Form.php
  2. 9 0
      tests/Zend/Form/FormTest.php

+ 4 - 0
library/Zend/Form.php

@@ -1782,6 +1782,10 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
     {
         $group = array();
         foreach ($elements as $element) {
+            if($element instanceof Zend_Form_Element) {
+                $element = $element->getId();
+            }
+
             if (isset($this->_elements[$element])) {
                 $add = $this->getElement($element);
                 if (null !== $add) {

+ 9 - 0
tests/Zend/Form/FormTest.php

@@ -4388,6 +4388,15 @@ class Zend_Form_FormTest extends PHPUnit_Framework_TestCase
         $html = $form->render($this->getView());
         $this->assertEquals(1, substr_count($html, 'Customer Type'), $html);
     }
+
+    public function testAddElementToDisplayGroupByElementInstance()
+    {
+        $element = new Zend_Form_Element_Text('foo');
+
+        $this->form->addElement($element);
+        $this->form->addDisplayGroup(array($element), 'bar');
+        $this->assertNotNull($this->form->getDisplayGroup('bar')->getElement('foo'));
+    }
 }
 
 class Zend_Form_FormTest_DisplayGroup extends Zend_Form_DisplayGroup