示例#1
0
 /**
  * Shows the widget
  */
 public function show()
 {
     $tag = new TEntry($this->name);
     $tag->setEditable(FALSE);
     $tag->setProperty('id', $this->name);
     $tag->setSize(40);
     $tag->setProperty('onchange', "aux = document.getElementsByName('{$this->text_name}'); aux[0].value = this.value;");
     $tag->show();
     // define the tag properties
     $this->tag->name = $this->text_name;
     $this->tag->onchange = "entry = document.getElementById('{$this->name}'); entry.value = this.value;";
     $this->tag->style = "width:{$this->size}px;";
     // tamanho em pixels
     // creates an empty <option> tag
     $option = new TElement('option');
     $option->add('');
     $option->value = '0';
     // valor da TAG
     // add the option tag to the combo
     $this->tag->add($option);
     if ($this->items) {
         // iterate the combobox items
         foreach ($this->items as $chave => $item) {
             // 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) {
                 // mark as selected
                 $option->selected = 1;
             }
             // add the option to the combo
             $this->tag->add($option);
         }
     }
     // verify whether the widget is editable
     if (!parent::getEditable()) {
         // make the widget read-only
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
     }
     // shows the combobox
     $this->tag->show();
 }