Browse Source

ZF-8709: Change label on radio button from explicit to implicit

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24840 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan 13 years ago
parent
commit
d2d9a70eb8
2 changed files with 18 additions and 18 deletions
  1. 1 1
      library/Zend/View/Helper/FormRadio.php
  2. 17 17
      tests/Zend/View/Helper/FormRadioTest.php

+ 1 - 1
library/Zend/View/Helper/FormRadio.php

@@ -157,7 +157,7 @@ class Zend_View_Helper_FormRadio extends Zend_View_Helper_FormElement
 
             // Wrap the radios in labels
             $radio = '<label'
-                    . $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">'
+                    . $this->_htmlAttribs($label_attribs) . '>'
                     . (('prepend' == $labelPlacement) ? $opt_label : '')
                     . '<input type="' . $this->_inputType . '"'
                     . ' name="' . $name . '"'

+ 17 - 17
tests/Zend/View/Helper/FormRadioTest.php

@@ -384,25 +384,26 @@ class Zend_View_Helper_FormRadioTest extends PHPUnit_Framework_TestCase
         $this->assertNotContains('style="white-space: nowrap;"', $html);
     }
 
-    public function testRadioLabelContainsForAttributeTag()
+    /**
+     * @group ZF-8709
+     */
+    public function testRadioLabelContainsNotForAttributeTag()
     {
-        $options = array(
-            'foo bar' => 'Foo',
-            'bar baz' => 'Bar',
-            'baz' => 'Baz'
+        $actual = $this->helper->formRadio(
+            array(
+                 'name'    => 'foo',
+                 'options' => array(
+                     'bar' => 'Bar',
+                     'baz' => 'Baz'
+                 ),
+            )
         );
-        $html = $this->helper->formRadio(array(
-            'name'    => 'foo[bar]',
-            'value'   => 'bar',
-            'options' => $options,
-        ));
 
-        require_once 'Zend/Filter/Alnum.php';
-        $filter = new Zend_Filter_Alnum();
-        foreach ($options as $key => $value) {
-            $id = 'foo-bar-' . $filter->filter($key);
-            $this->assertRegexp('/<label([^>]*)(for="' . $id . '")/', $html);
-        }
+        $expected = '<label><input type="radio" name="foo" id="foo-bar" value="bar">Bar</label><br />'
+                  . "\n"
+                  . '<label><input type="radio" name="foo" id="foo-baz" value="baz">Baz</label>';
+
+        $this->assertSame($expected, $actual);
     }
     
     /**
@@ -422,7 +423,6 @@ class Zend_View_Helper_FormRadioTest extends PHPUnit_Framework_TestCase
         $html = $formRadio->formRadio($name, -1, null, $options);
         foreach ( $options as $key=>$value ) {
             $fid = "{$name}-{$key}";
-            $this->assertRegExp('/<label([^>]*)(for="'.$fid.'")/', $html);
             $this->assertRegExp('/<input([^>]*)(id="'.$fid.'")/', $html);
         }