Beispiel #1
0
 public function render()
 {
     $opt = null;
     if (is_array($this->options)) {
         $opt = HTML::OptionListing($this->options, $this->getValue(), null, (bool) $this->ignore_keys);
     }
     return HTML::Select($opt, $this->getName(), null, $this->getAttributes(false), $this->getPlaceholder());
 }
Beispiel #2
0
 /** Генерация тега SELECT со списком опций */
 public function asSelect($placeholder = null, $attr = null, $value = null)
 {
     if (!$this->getOptions()) {
         return false;
     }
     if (is_null($value)) {
         $value = $this->getCleanValue();
     }
     return HTML::Select($this->asSelectOptions($value), $this->getColumn(), null, $attr, $placeholder);
 }
Beispiel #3
0
 function testSelect()
 {
     $s = HTML::Select(HTML::Option('hello'), 'myname');
     $this->assertSelectCount('select[name=myname] option[value=hello]', true, $s, 'Простой селект');
     $s = HTML::Select(array(1 => 'Привет', 2 => 'Пока'), 'hello', 2, 'myclass', 'Выбор');
     $this->assertSelectCount('select[class=myclass]', true, $s, 'Атрибуты');
     $this->assertGreaterThan(0, strpos($s, '<option value="">Выбор</option>'), 'Заголовок');
     $this->assertGreaterThan(0, strpos($s, '<option value="1">Привет</option>'), 'Первый пункт не выбран');
     $this->assertGreaterThan(0, strpos($s, '<option selected="selected" value="2">Пока</option>'), 'Второй пункт выбран');
 }
Beispiel #4
0
 /** Варианты выбора сортировки в виде SELECT */
 public function getOrderByAsSelect($placeholder = null, $attr = null, $selected = null)
 {
     return HTML::Select($this->getOrderByAsSelectOptions($selected), OrderBy::URL_PARAM, null, $attr, $placeholder);
 }