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()); }
/** Генерация тега 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); }
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>'), 'Второй пункт выбран'); }
/** Варианты выбора сортировки в виде SELECT */ public function getOrderByAsSelect($placeholder = null, $attr = null, $selected = null) { return HTML::Select($this->getOrderByAsSelectOptions($selected), OrderBy::URL_PARAM, null, $attr, $placeholder); }