public function run()
{
if ($this->form) {
Html::addCssClass($this->options, 'datepicker-from');
Html::addCssClass($this->optionsTo, 'datepicker-to');
$inputFrom = $this->form->field($this->model, $this->attribute, ['template' => '{input}{error}', 'options' => ['class' => 'input-group datepicker-range']])->textInput($this->options);
$inputTo = $this->form->field($this->model, $this->attributeTo, ['template' => '{input}{error}', 'options' => ['class' => 'input-group datepicker-range']])->textInput($this->optionsTo);
} else {
$inputFrom = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
$inputTo = $this->hasModel() ? Html::activeTextInput($this->model, $this->attributeTo, $this->optionsTo) : Html::textInput($this->nameTo, $this->valueTo, $this->optionsTo);
}
echo Html::tag('div', strtr($this->_template, ['{inputFrom}' => $inputFrom, '{labelTo}' => $this->labelTo, '{inputTo}' => $inputTo]), $this->containerOptions);
$this->registerClientScript();
}