Browse Source

ZF-10679: Applying patch from Marc Hodgins

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23425 44c647ce-9c0f-0410-b52a-842ac1e357ba
bittarman 15 years ago
parent
commit
de5c638058

+ 1 - 1
library/Zend/Form/Decorator/Fieldset.php

@@ -72,7 +72,7 @@ class Zend_Form_Decorator_Fieldset extends Zend_Form_Decorator_Abstract
         $options = parent::getOptions();
         if (null !== ($element = $this->getElement())) {
             $attribs = $element->getAttribs();
-            $options = array_merge($options, $attribs);
+            $options = array_merge($attribs, $options);
             $this->setOptions($options);
         }
         return $options;

+ 16 - 1
tests/Zend/Form/Decorator/FieldsetTest.php

@@ -34,7 +34,7 @@ require_once 'Zend/Form/Decorator/Fieldset.php';
 require_once 'Zend/Form.php';
 require_once 'Zend/Form/Element.php';
 require_once 'Zend/View.php';
-
+require_once 'Zend/Form/Subform.php';
 /**
  * Test class for Zend_Form_Decorator_Fieldset
  *
@@ -219,6 +219,21 @@ class Zend_Form_Decorator_FieldsetTest extends PHPUnit_Framework_TestCase
         $this->assertContains('<fieldset', $test, $test);
         $this->assertNotContains('helper="', $test);
     }
+
+    /**
+     * @group ZF-10679
+     */
+    public function testFieldsetIdOverridesFormId()
+    {
+        $form = new Zend_Form();
+        $form->setName('bar')
+             ->setAttrib('id', 'form-id')
+             ->setView($this->getView());
+        $html = $this->decorator->setElement($form)
+                                ->setOption('id', 'fieldset-id')
+                                ->render('content');
+        $this->assertContains('<fieldset id="fieldset-id"', $html);
+    }
 }
 
 // Call Zend_Form_Decorator_FieldsetTest::main() if this source file is executed directly.