/** * Shows the widget */ public function show() { // define the tag properties $this->tag->name = $this->name; // tag name $this->tag->style = "width:{$this->size}px"; // size in pixels // creates an empty <option> tag $option = new TElement('option'); $option->add(''); $option->value = ''; // tag value // add the option tag to the combo $this->tag->add($option); if ($this->items) { // iterate the combobox items foreach ($this->items as $chave => $item) { if (substr($chave, 0, 3) == '>>>') { $optgroup = new TElement('optgroup'); $optgroup->label = $item; // add the option to the combo $this->tag->add($optgroup); } else { // creates an <option> tag $option = new TElement('option'); $option->value = $chave; // define the index $option->add($item); // add the item label // verify if this option is selected if ($chave == $this->value and $this->value !== NULL) { // mark as selected $option->selected = 1; } if (isset($optgroup)) { $optgroup->add($option); } else { $this->tag->add($option); } } } } // verify whether the widget is editable if (parent::getEditable()) { if (isset($this->changeaction)) { $string_action = $this->changeaction->serialize(FALSE); $this->setProperty('onChange', "serialform=(\$('#{$this->formName}').serialize());\n ajaxLookup('{$string_action}&'+serialform, this)"); } } else { // make the widget read-only $this->tag->readonly = "1"; $this->tag->disabled = "disabled"; $this->tag->{'class'} = 'tfield_disabled'; // CSS } // shows the combobox $this->tag->show(); }