--- library/Zend/View/Helper/FormSelect.php (revision 24045) +++ library/Zend/View/Helper/FormSelect.php (working copy) @@ -123,8 +123,11 @@ if (null !== $translator) { $opt_value = $translator->translate($opt_value); } + $opt_id = ' id="' . $this->view->escape($id) . '-optgroup-' + . $this->view->escape($opt_value) . '"'; $list[] = ''; foreach ($opt_label as $val => $lab) { $list[] = $this->_build($val, $lab, $value, $disable); Index: tests/Zend/View/Helper/FormSelectTest.php =================================================================== --- tests/Zend/View/Helper/FormSelectTest.php (revision 24045) +++ tests/Zend/View/Helper/FormSelectTest.php (working copy) @@ -311,6 +311,23 @@ $this->assertRegexp('/]*?(name="baz\[\]")/', $html, $html); $this->assertNotRegexp('/]*?(multiple="multiple")/', $html, $html); } + + /** @group ZF-8252 */ + public function testOptgroupHasAnId() + { + $html = $this->helper->formSelect(array( + 'name' => 'baz', + 'options' => array( + 'foo' => 'Foo', + 'bar' => array( + '1' => 'one', + '2' => 'two' + ), + 'baz' => 'Baz,' + ) + )); + $this->assertRegexp('/]*?id="baz-optgroup-bar"[^>]*?"bar"[^>]*?/', $html, $html); + } } // Call Zend_View_Helper_FormSelectTest::main() if this source file is executed directly.