public function toHtml()
 {
     $select = new HTML('select');
     if ($this->readOnly) {
         $select->attr('disabled', 'disabled');
     }
     if ($this->multiple) {
         $select->attr('multiple', 'multiple');
     }
     if ($this->name === null) {
         $this->name = $this->id;
     }
     $select->addCssClasses($this->cssClasses)->css('form-control')->attr('name', $this->name)->attr('id', $this->id);
     foreach ($this->options as $option) {
         $optionHtml = new Html('option');
         $optionHtml->attr('value', $option['value'])->text($option['text']);
         if ($this->isSelected($option['value'])) {
             $optionHtml->attr('selected', 'selected');
         }
         $select->text($optionHtml);
     }
     return $select->render();
 }
 /**
  * @inheritdoc
  */
 public function toHtml()
 {
     $select = Html::create('select')->css('lookup')->css('form-control')->addCssClasses($this->cssClasses)->attr('name', $this->name)->attr('id', $this->id);
     if ($this->groupfield !== null) {
         $select->css('grouped');
     }
     if ($this->multiple) {
         $select->attr('multiple', 'multiple');
         $select->attr('name', $this->name . '[]');
     }
     if ($this->readOnly) {
         $select->attr('disabled', 'disabled');
     }
     // Falls null-Wert angezeigt werden soll
     if ($this->showNullValue) {
         Html::create('option')->attr('value', $this->nullValue)->text($this->nullText)->addTo($select);
     }
     $groupValue = null;
     $optGroup = null;
     // Objekte laden, damit die Formatierungen angewendet werden
     $items = $this->lookupentity->filter($this->filter, 3000);
     if (!$this->parent instanceof SubmitDataControl && count($items) > 50) {
         $this->setUseChosen(true);
     }
     foreach ($items as $curItem) {
         // Gruppenkopf
         if ($this->groupfield != null && $groupValue !== $this->getEntityText($curItem, $this->groupfield)) {
             $optGroup = new Html('optgroup');
             $optGroup->attr('label', $this->getEntityText($curItem, $this->groupfield))->addTo($select);
             $groupValue = $this->getEntityText($curItem, $this->groupfield);
         }
         $text = $this->getEntityText($curItem, $this->textfield);
         if ($this->textfield2 !== null) {
             $text .= ', ' . $this->getEntityText($curItem, $this->textfield2);
         }
         $option = new Html('option');
         $option->attr('value', $curItem->val($this->valuefield))->text($text);
         if ($curItem->val($this->valuefield) == $this->selectedValue) {
             $option->attr('selected', 'selected');
         }
         if ($optGroup !== null) {
             $optGroup->text($option);
         } else {
             $select->text($option);
         }
     }
     return $select->render();
 }