/** * Constructor * * Instantiate the datalist text input form element * * @param string $name * @param array $values * @param string $value * @param string $indent * @return Datalist */ public function __construct($name, array $values, $value = null, $indent = null) { parent::__construct($name, $value, $indent); $this->setAttribute('list', $name . '_datalist'); if (null !== $values) { $this->datalist = new Child('datalist', null, null, $this->indent); $this->datalist->setAttribute('id', $name . '_datalist'); foreach ($values as $key => $val) { $this->datalist->addChild((new Child('option', $val))->setAttribute('value', $key)); } } }