pfsense/usr/local/www/classes/Form/Select.class.php
Sjon Hortensius 69f9ff4034 final touches on Forms
system - removed trailing unused form-html
Form - set proper width for submit-button column
Element - support returning raw-list for Inputs
Group,Input - renamed getColumnWidth to getWidth
Input - make setWidth consistent with Form->setWidth, directly add
  proper class to column
2015-01-27 21:33:41 +01:00

33 lines
671 B
PHP

<?php
class Form_Select extends Form_Input
{
protected $_values;
public function __construct($title, $value, array $values, $allowMultiple = false)
{
parent::__construct($title);
if ($allowMultiple)
$this->_attributes['multiple'] = 'multiple';
$this->_values = $values;
}
protected function _getInput()
{
$element = 'select';
foreach ($this->_attributes as $key => $value)
$element .= ' '.$key.'="'. htmlspecialchars($value).'"';
$options = '';
foreach ($this->_values as $value => $name)
$options .= '<option value="'. htmlspecialchars($value) .'">'. $name .'</option>';
return <<<EOT
<{$element}>
{$options}
</select>
EOT;
}
}