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
 /** Генерация списка опций в виде тегов <option> */
 public function asSelectOptions($value = null)
 {
     if (!$this->getOptions()) {
         return false;
     }
     if (is_null($value)) {
         $value = $this->getCleanValue();
     }
     return HTML::OptionListing($this->getOptions(), $value, null, $this->getOptionsIgnoreKeys());
 }
Beispiel #3
0
 function testOptionListing()
 {
     $arr = array('one', 'two');
     $ol = HTML::OptionListing($arr, 'two', null, true);
     $exp = '<option value="one">one</option>' . "\n" . '<option selected="selected" value="two">two</option>' . "\n";
     $this->assertEquals($exp, $ol, 'Список по значениям');
     $arr = array(1 => 'one', 2 => 'two');
     $ol = HTML::OptionListing($arr, 2, 'choose');
     $this->assertSelectCount('optgroup[label=choose] option', 2, $ol, 'OPTGROUP с 2 опциями');
     $this->assertSelectCount('option[value=1]', true, $ol, 'Опции по ключ-значению 1');
     $this->assertSelectCount('option[value=2]', true, $ol, 'Опции по ключ-значению 2');
     $this->assertGreaterThan(0, strpos($ol, '<option selected="selected" value="2">two</option>'), 'Выделен пункт №2');
     $arr = array(0 => 'Нет', 1 => 'Да');
     $ol = HTML::OptionListing($arr, null);
     $this->assertSelectCount('option[selected=selected]', false, $ol, 'Никакой пункт не выбран');
     $ol = HTML::OptionListing($arr, 0);
     $this->assertSelectCount('option[selected=selected]', true, $ol, 'Выбран пункт Нет');
 }
Beispiel #4
0
 /** Варианты выбора сортировки в виде опций для SELECT */
 public function getOrderByAsSelectOptions($selected = null)
 {
     if (is_null($selected)) {
         $o = $this->getOrderBy();
         $selected = $o ? $o->asUrlParameter() : null;
     }
     return HTML::OptionListing($this->getOrderByOptionsForSelect(), $selected);
 }