/** * Executes the widget. * @return string the result of widget execution to be outputted. */ public function run() { $this->registerAssets(); Html::addCssClass($this->options, 'clockpicker'); if ($this->hasModel()) { $this->options['data-value'] = isset($this->value) ? $this->value : Html::getAttributeValue($this->model, $this->attribute); return Html::activeInput('time', $this->model, $this->attribute, $this->options); } else { $this->options['data-value'] = $this->value; return Html::input('time', $this->name, $this->value, $this->options); } }
/** * Render the switch button checkbox. * @return string * @uses [yii\helper\BaseHtml::checkbox()](http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#checkbox()-detail) */ protected function renderSwitch() { $value = ArrayHelper::getValue($this->inputOptions, 'value', null); if ($this->hasModel()) { $attributeValue = Html::getAttributeValue($this->model, $this->attribute); $this->checked = "{$value}" === "{$attributeValue}"; } $name = ArrayHelper::remove($this->inputOptions, 'name', null); return implode("\n", [Html::beginTag('label'), $this->renderLabel('off'), Html::checkbox($name, $this->checked, $this->inputOptions), Html::tag('span', '', ['class' => 'lever']), $this->renderLabel('on'), Html::endTag('label')]); }