allow to set width of selection boxes

This commit is contained in:
Roland Gruber 2010-10-18 19:45:35 +00:00
parent 9996e4c2eb
commit c4766bed83
1 changed files with 16 additions and 1 deletions

View File

@ -675,6 +675,8 @@ class htmlSelect extends htmlElement {
private $rightToLeftTextDirection = false; private $rightToLeftTextDirection = false;
/** enabled or disabled */ /** enabled or disabled */
private $isEnabled = true; private $isEnabled = true;
/** width of input element */
private $width = '';
/** /**
* Constructor. * Constructor.
@ -732,7 +734,11 @@ class htmlSelect extends htmlElement {
if (!$this->isEnabled) { if (!$this->isEnabled) {
$disabled = ' disabled'; $disabled = ' disabled';
} }
echo '<select' . $class . $name . $size . $multi . $disabled . ' tabindex="' . $tabindex . "\">\n"; $style = '';
if ($this->width != '') {
$style = ' style="width: ' . $this->width . '"';
}
echo '<select' . $class . $style . $name . $size . $multi . $disabled . ' tabindex="' . $tabindex . "\">\n";
$tabindex++; $tabindex++;
if ($this->containsOptgroups) { if ($this->containsOptgroups) {
foreach ($this->elements as $label => $elements) { foreach ($this->elements as $label => $elements) {
@ -847,6 +853,15 @@ class htmlSelect extends htmlElement {
$this->isEnabled = $isEnabled; $this->isEnabled = $isEnabled;
} }
/**
* Specifies the width of this selection box.
*
* @param String $width width (e.g. 20em)
*/
public function setWidth($width) {
$this->width = htmlspecialchars($width);
}
} }
/** /**