diff -r 000000000000 -r 4eba9c11703f web/Zend/View/Helper/FormSelect.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/View/Helper/FormSelect.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,178 @@ +\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; + } + +}