Closed hhniao closed 6 years ago
im writen a new class extends from your code, and modify follow line.
if (!empty($this->value)) {
$dates = explode($this->_separator, $this->value);
if (count($dates) > 1) {
$this->pluginOptions['startDate'] = $dates[0];
$this->pluginOptions['endDate'] = $dates[1];
$this->initRangeValue('start', $dates[0]);
$this->initRangeValue('end', $dates[1]);
}
//this line has been modify,may be must change to jadgement is valid date
} elseif (!empty($this->value) && $this->startAttribute && $this->endAttribute) {
$start = $this->getRangeValue('start');
$end = $this->getRangeValue('end');
$this->value = $start . $this->_separator . $end;
if ($this->hasModel()) {
$attr = $this->attribute;
$this->model->$attr = $this->value;
}
$this->pluginOptions['startDate'] = $start;
$this->pluginOptions['endDate'] = $end;
}
im using it on yii2 filter of girdview; ` [ 'attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d H:i:s'], 'filter' => DateRangePicker::widget([ 'name' => 'AdvertisementQuery[created_at]', 'value' => $searchModel->created_at, 'startAttribute' => 'start', 'endAttribute' => 'end',
` when i set startAttribute and endAttribute and then show me invalid date. because on this configuration situation it will generate javascript code like this:
if value or startDate or endDate is null of daterangepicker_93cc6fdc, daterangepicker will show invalid date error.
so kartik\daterange\DateRangePicker::initSettings must do not set startDate and endDate and value in pluginOptions on line 340,345,346;
please modify it. thanks!