2
0
Просмотр исходного кода

merge r25108 to release-1.12

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25109 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob 13 лет назад
Родитель
Сommit
85097da0b3
2 измененных файлов с 50 добавлено и 3 удалено
  1. 8 2
      library/Zend/Form/Element/Radio.php
  2. 42 1
      tests/Zend/Form/Element/RadioTest.php

+ 8 - 2
library/Zend/Form/Element/Radio.php

@@ -53,8 +53,14 @@ class Zend_Form_Element_Radio extends Zend_Form_Element_Multi
             return $this;
         }
         parent::loadDefaultDecorators();
-        $this->addDecorator('Label', array('tag' => 'dt',
-                                           'disableFor' => true));
+
+        // Disable 'for' attribute
+        if (isset($this->_decorators['Label'])
+            && !isset($this->_decorators['Label']['options']['disableFor']))
+        {
+             $this->_decorators['Label']['options']['disableFor'] = true;
+        }
+
         return $this;
     }
 }

+ 42 - 1
tests/Zend/Form/Element/RadioTest.php

@@ -181,7 +181,9 @@ class Zend_Form_Element_RadioTest extends PHPUnit_Framework_TestCase
 
         $element = $form->getElement('foo');
 
-        $this->assertType('My_Decorator_Label', $element->getDecorator('Label'));
+        $this->assertTrue(
+            $element->getDecorator('Label') instanceof My_Decorator_Label
+        );
     }
 
     /**
@@ -199,6 +201,45 @@ class Zend_Form_Element_RadioTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-11517
+     */
+    public function testCreationWithIndividualDecoratorsAsConstructorOptionsWithoutLabel()
+    {
+        $element = new Zend_Form_Element_Radio(array(
+            'name'         => 'foo',
+            'multiOptions' => array(
+                'bar'  => 'Bar',
+                'baz'  => 'Baz',
+            ),
+            'decorators' => array(
+                'ViewHelper',
+            ),
+        ));
+
+        $this->assertFalse($element->getDecorator('label'));
+    }
+
+    /**
+     * @group ZF-11517
+     */
+    public function testRenderingWithIndividualDecoratorsAsConstructorOptionsWithoutLabel()
+    {
+        $element = new Zend_Form_Element_Radio(array(
+            'name'         => 'foo',
+            'multiOptions' => array(
+                'bar'  => 'Bar',
+                'baz'  => 'Baz',
+            ),
+            'decorators' => array(
+                'ViewHelper',
+            ),
+        ));
+
+        $html = $element->render($this->getView());
+        $this->assertNotContains('<dt id="foo-label">&#160;</dt>', $html);
+    }
+
+    /**
      * Used by test methods susceptible to ZF-2794, marks a test as incomplete
      *
      * @link   http://framework.zend.com/issues/browse/ZF-2794