This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Description
Hi,
here is a usecase:
DateTimePicker::widget([
'model' => $searchModel,
'attribute' => 'sent_at',
'language' => 'en',
'size' => 'ms',
'template' => "{reset}{input}",
'clientOptions' => [
'autoclose' => true,
'minView'=> 'month',
'format' => 'M d, yyyy',
'todayBtn' => true
]
]);
As you can see the template option was adjusted. So basically the calendar button is not needed but the reset button is. Changing of the template this way makes the Reset button disappear, which is obvious following the code from the widget implementation (run() method):
...
$input = $this->hasModel()
? Html::activeTextInput($this->model, $this->attribute, $this->options)
: Html::textInput($this->name, $this->value, $this->options);
...
if (strpos($this->template, '{button}') !== false || $this->inline) {
$input = Html::tag(
'div',
strtr($this->template, ['{input}' => $input, '{reset}' => $resetAddon, '{button}' => $pickerAddon]),
$this->containerOptions
);
}
echo $input;
...
So if there is not {button} in the template, the widget is rendered as single text input
Hope this will help