* @copyright 2010, Enrise
* @license http://www.opensource.org/licenses/bsd-license.php
* @version $Id: $
*/
/**
* View helper for generating a HTML5 datalist
*
* @category Glitch
* @package Glitch_View
* @subpackage Helper
*/
class Glitch_View_Helper_FormDatalist extends Zend_View_Helper_FormSelect
{
/**
* Generates 'select' list of options.
*
* @access public
*
* @param string|array $name If a string, the element name. If an
* array, all other parameters are ignored, and the array elements
* are extracted in place of added parameters.
*
* @param mixed $value The option value to mark as 'selected'; if an
* array, will mark all values in the array as 'selected' (used for
* multiple-select elements).
*
* @param array|string $attribs Attributes added to the 'select' tag.
*
* @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.
*
* @param string $listsep When disabled, use this list separator string
* between list values.
*
* @return string The select tag and options XHTML.
*/
public function formDatalist($name, $value = null, $attribs = null,
$options = null, $listsep = " \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);
// Build the surrounding select element first.
$xhtml = '';
$xhtml .= '";
return $xhtml;
}
}