function testCheckbox() { $c = HTML::Checkbox('hello'); $this->assertSelectCount('input[type=checkbox]', true, $c, 'Тип'); $this->assertSelectCount('input[name=hello]', true, $c, 'Name'); $this->assertSelectCount('input[value=1]', true, $c, 'Значение по-умолчанию'); $this->assertSelectCount('input[checked=checked]', false, $c, 'Не отмечен'); $c = HTML::Checkbox('hello', true, 123, 'myclass'); $this->assertSelectCount('input[checked=checked]', true, $c, 'Отмечен'); $this->assertSelectCount('input[value=123]', true, $c, 'Значение'); $this->assertSelectCount('input[class=myclass]', true, $c, 'Класс'); $c = HTML::Checkbox('hello', null, null, null, 'Привет'); $this->assertSelectCount('label input', true, $c, 'Чекбокс завернутый в лейбл'); $this->assertTrue(strpos($c, 'Привет') > 0, 'Текст лейбла'); }
public function render($with_label = true) { return HTML::Checkbox($this->getName(), $this->getIsChecked(), $this->getCheckboxValue(), $this->getAttributes(false), $with_label ? $this->getLabel() : null); }