Forráskód Böngészése

ZF-9682: Element_Radio loads Decorator_Label before rendering

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22151 44c647ce-9c0f-0410-b52a-842ac1e357ba
alab 15 éve
szülő
commit
8c90161ef7

+ 5 - 3
library/Zend/Form/Element/Radio.php

@@ -49,9 +49,11 @@ class Zend_Form_Element_Radio extends Zend_Form_Element_Multi
      */
     public function loadDefaultDecorators()
     {
-        parent::loadDefaultDecorators();
-        if (false !== $decorator = $this->getDecorator('Label')) {
-            $decorator->setOption('disableFor', true);
+        if ($this->loadDefaultDecoratorsIsDisabled()) {
+            return;
         }
+        parent::loadDefaultDecorators();
+        $this->addDecorator('Label', array('tag' => 'dt',
+                                           'disableFor' => true));
     }
 }

+ 15 - 0
tests/Zend/Form/Element/RadioTest.php

@@ -172,6 +172,21 @@ class Zend_Form_Element_RadioTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-9682
+     */
+    public function testCustomLabelDecorator()
+    {
+        $form = new Zend_Form();
+        $form->addElementPrefixPath('My_Decorator', dirname(__FILE__) . '/../_files/decorators/', 'decorator');
+
+        $form->addElement($this->element);
+
+        $element = $form->getElement('foo');
+
+        $this->assertType('My_Decorator_Label', $element->getDecorator('Label'));
+    }
+
+    /**
      * @group ZF-6426
      */
     public function testRenderingShouldCreateLabelWithoutForAttribute()