Skip to content

Commit a2f7095

Browse files
committed
Update DateRangePicker.php
Change to allow overriding the defaultRanges in the config using the 'ranges' parameter
1 parent 898b1ff commit a2f7095

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/DateRangePicker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,15 @@ protected function initRange()
432432
$beg = "{$m}.startOf('day')";
433433
$end = "{$m}.endOf('day')";
434434
$last = "{$m}.subtract(1, 'month')";
435-
$this->pluginOptions['ranges'] = [
435+
$defaultRanges = [
436436
Yii::t('kvdrp', 'Today') => [$beg, $end],
437437
Yii::t('kvdrp', 'Yesterday') => ["{$beg}.subtract(1,'days')", "{$end}.subtract(1,'days')"],
438438
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["{$beg}.subtract(6, 'days')", $end],
439439
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["{$beg}.subtract(29, 'days')", $end],
440440
Yii::t('kvdrp', 'This Month') => ["{$m}.startOf('month')", "{$m}.endOf('month')"],
441441
Yii::t('kvdrp', 'Last Month') => ["{$last}.startOf('month')", "{$last}.endOf('month')"],
442442
];
443+
$this->pluginOptions['ranges'] = ArrayHelper::getValue($this->pluginOptions, 'ranges', $defaultRanges);
443444
if (empty($this->value)) {
444445
$this->pluginOptions['startDate'] = new JsExpression("{$m}.startOf('day')");
445446
$this->pluginOptions['endDate'] = new JsExpression($m);

0 commit comments

Comments
 (0)