-
Notifications
You must be signed in to change notification settings - Fork 3
/
DatePicker.php
30 lines (26 loc) · 909 Bytes
/
DatePicker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* @author Anton Tuyakhov <atuyakhov@gmail.com>
*/
namespace tuyakhov\materialize;
use yii\helpers\Html;
use yii\widgets\InputWidget;
class DatePicker extends InputWidget
{
use WidgetTrait;
public function run()
{
if (!isset($this->clientOptions['container'])) {
$this->clientOptions['container'] = 'body';
}
$this->registerJqueryPlugin('pickadate');
Html::addCssClass($this->options, 'datepicker');
if ($this->hasModel()) {
$this->options['data-value'] = isset($this->value) ? $this->value : Html::getAttributeValue($this->model, $this->attribute);
return Html::activeInput('date', $this->model, $this->attribute, $this->options);
} else {
$this->options['data-value'] = $this->value;
return Html::input('date', $this->name, $this->value, $this->options);
}
}
}