diff -r 5e7a0fedabdf -r 877f952ae2bd web/lib/Zend/View/Helper/FormSelect.php --- a/web/lib/Zend/View/Helper/FormSelect.php Thu Mar 21 17:31:31 2013 +0100 +++ b/web/lib/Zend/View/Helper/FormSelect.php Thu Mar 21 19:50:53 2013 +0100 @@ -15,9 +15,9 @@ * @category Zend * @package Zend_View * @subpackage Helper - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FormSelect.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: FormSelect.php 25187 2013-01-08 08:21:00Z frosch $ */ @@ -33,7 +33,7 @@ * @category Zend * @package Zend_View * @subpackage Helper - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_View_Helper_FormSelect extends Zend_View_Helper_FormElement @@ -52,6 +52,9 @@ * multiple-select elements). * * @param array|string $attribs Attributes added to the 'select' tag. + * the optional 'optionClasses' attribute is used to add a class to + * the options within the select (associative array linking the option + * value to the desired class) * * @param array $options An array of key-value pairs where the array * key is the radio value, and the array value is the radio text. @@ -96,6 +99,13 @@ unset($attribs['multiple']); } + // handle the options classes + $optionClasses = array(); + if (isset($attribs['optionClasses'])) { + $optionClasses = $attribs['optionClasses']; + unset($attribs['optionClasses']); + } + // now start building the XHTML. $disabled = ''; if (true === $disable) { @@ -123,15 +133,18 @@ 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); + $list[] = $this->_build($val, $lab, $value, $disable, $optionClasses); } $list[] = ''; } else { - $list[] = $this->_build($opt_value, $opt_label, $value, $disable); + $list[] = $this->_build($opt_value, $opt_label, $value, $disable, $optionClasses); } } @@ -148,18 +161,27 @@ * @param string $label Options Label * @param array $selected The option value(s) to mark as 'selected' * @param array|bool $disable Whether the select is disabled, or individual options are + * @param array $optionClasses The classes to associate with each option value * @return string Option Tag XHTML */ - protected function _build($value, $label, $selected, $disable) + protected function _build($value, $label, $selected, $disable, $optionClasses = array()) { if (is_bool($disable)) { $disable = array(); } + $class = null; + if (array_key_exists($value, $optionClasses)) { + $class = $optionClasses[$value]; + } + + $opt = '