Index: FormSelect.php =================================================================== --- FormSelect.php (revision 23862) +++ FormSelect.php (working copy) @@ -1,178 +1,198 @@ -\n") - { - $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); - extract($info); // name, id, value, attribs, options, listsep, disable - - // force $value to array so we can compare multiple values to multiple - // options; also ensure it's a string for comparison purposes. - $value = array_map('strval', (array) $value); - - // check if element may have multiple values - $multiple = ''; - - if (substr($name, -2) == '[]') { - // multiple implied by the name - $multiple = ' multiple="multiple"'; - } - - if (isset($attribs['multiple'])) { - // Attribute set - if ($attribs['multiple']) { - // True attribute; set multiple attribute - $multiple = ' multiple="multiple"'; - - // Make sure name indicates multiple values are allowed - if (!empty($multiple) && (substr($name, -2) != '[]')) { - $name .= '[]'; - } - } else { - // False attribute; ensure attribute not set - $multiple = ''; - } - unset($attribs['multiple']); - } - - // now start building the XHTML. - $disabled = ''; - if (true === $disable) { - $disabled = ' disabled="disabled"'; - } - - // Build the surrounding select element first. - $xhtml = '_htmlAttribs($attribs) - . ">\n "; - - // build the list of options - $list = array(); - $translator = $this->getTranslator(); - foreach ((array) $options as $opt_value => $opt_label) { - if (is_array($opt_label)) { - $opt_disable = ''; - if (is_array($disable) && in_array($opt_value, $disable)) { - $opt_disable = ' disabled="disabled"'; - } - if (null !== $translator) { - $opt_value = $translator->translate($opt_value); - } - $list[] = ''; - foreach ($opt_label as $val => $lab) { - $list[] = $this->_build($val, $lab, $value, $disable); - } - $list[] = ''; - } else { - $list[] = $this->_build($opt_value, $opt_label, $value, $disable); - } - } - - // add the options to the xhtml and close the select - $xhtml .= implode("\n ", $list) . "\n"; - - return $xhtml; - } - - /** - * Builds the actual "; - - return $opt; - } - -} +\n") + { + $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); + extract($info); // name, id, value, attribs, options, listsep, disable + + // force $value to array so we can compare multiple values to multiple + // options; also ensure it's a string for comparison purposes. + $value = array_map('strval', (array) $value); + + // check if element may have multiple values + $multiple = ''; + + if (substr($name, -2) == '[]') { + // multiple implied by the name + $multiple = ' multiple="multiple"'; + } + + if (isset($attribs['multiple'])) { + // Attribute set + if ($attribs['multiple']) { + // True attribute; set multiple attribute + $multiple = ' multiple="multiple"'; + + // Make sure name indicates multiple values are allowed + if (!empty($multiple) && (substr($name, -2) != '[]')) { + $name .= '[]'; + } + } else { + // False attribute; ensure attribute not set + $multiple = ''; + } + 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) { + $disabled = ' disabled="disabled"'; + } + + // Build the surrounding select element first. + $xhtml = '_htmlAttribs($attribs) + . ">\n "; + + // build the list of options + $list = array(); + $translator = $this->getTranslator(); + foreach ((array) $options as $opt_value => $opt_label) { + if (is_array($opt_label)) { + $opt_disable = ''; + if (is_array($disable) && in_array($opt_value, $disable)) { + $opt_disable = ' disabled="disabled"'; + } + if (null !== $translator) { + $opt_value = $translator->translate($opt_value); + } + $list[] = ''; + foreach ($opt_label as $val => $lab) { + $list[] = $this->_build($val, $lab, $value, $disable, $optionClasses); + } + $list[] = ''; + } else { + $list[] = $this->_build($opt_value, $opt_label, $value, $disable, $optionClasses); + } + } + + // add the options to the xhtml and close the select + $xhtml .= implode("\n ", $list) . "\n"; + + return $xhtml; + } + + /** + * Builds the actual "; + + return $opt; + } + +}