/** * Render input field. * * @return Brick */ public function input() { // Provide a default label for the checkbox $text = $this->text() ? $this->text() : 'Disable comments?'; // Build the input field $wrapper = parent::input(); $input = $wrapper->html(); $wrapper->text($text); $wrapper->prepend($input); return $wrapper; }
public function input() { $input = new Brick('input', null); $input->addClass('tgl'); $input->attr(array('id' => $this->id(), 'name' => $this->name(), 'required' => $this->required(), 'autofocus' => $this->autofocus(), 'autocomplete' => $this->autocomplete(), 'readonly' => $this->readonly(), 'type' => 'checkbox', 'checked' => v::accepted($this->value()))); $btn = new Brick('label', null); $btn->addClass('tgl-btn'); $btn->attr('for', $this->id()); $wrapper = parent::input(); $wrapper->tag('label'); $wrapper->html($this->i18n($this->text())); $wrapper->attr('for', $this->id()); $wrapper->removeAttr('id'); $wrapper->addClass('input-with-checkbox'); $wrapper->prepend($btn); $wrapper->prepend($input); return $wrapper; }