Hi Katik,
I had some problem to set the ranges,
I’ve tried
$datepicker = DateRangePicker::widget([
'name'=>'date_range_1',
'useWithAddon'=>false,
'language'=>'it', // from demo config
'hideInput'=>true, // from demo config
'presetDropdown'=>true, // from demo config
'pluginOptions'=>[
'format'=>'d/MM/YY', // from demo config
'separator'=>' - ', // from demo config
'opens'=>'right',
'ranges' => [
"Oggi" => ["moment()", "moment()"],
"Ieri" => ["moment().subtract('days', 1)", "moment().subtract('days', 1)"],
"Mese Corrente" => ["moment().startOf('month')", "moment().endOf('month')"],
"Mese Scorso" => ["moment().subtract('month', 1).startOf('month')", "moment().subtract('month', 1).endOf('month')"],
],
],
]);
but seems the extension override my setting.
So I had to change the Inizializing pluginOption range list addind one more if before setting $this->pluginOptions[‘ranges’].
/**
* Initializes the pluginOptions range list
*/
protected function initRange()
{
if ($this->presetDropdown) {
$this->initRangeExpr = true;
if (!isset($this->pluginOptions['ranges'])) // test ranges before set
$this->pluginOptions['ranges'] = [
Yii::t('kvdrp', "Today") => ["moment()", "moment()"],
Yii::t('kvdrp', "Yesterday") => ["moment().subtract('days', 1)", "moment().subtract('days', 1)"],
Yii::t('kvdrp', "Last {n} Days", ['n'=>7]) => ["moment().subtract('days', 6)", "moment()"],
Yii::t('kvdrp', "Last {n} Days", ['n'=>30]) => ["moment().subtract('days', 29)", "moment()"],
Yii::t('kvdrp', "This Month") => ["moment().startOf('month')", "moment().endOf('month')"],
Yii::t('kvdrp', "Last Month") => ["moment().subtract('month', 1).startOf('month')", "moment().subtract('month', 1).endOf('month')"],
];
$this->pluginOptions['startDate'] = new JsExpression("moment().subtract('days', 29)");
$this->pluginOptions['endDate'] = new JsExpression("moment()");
}
if (!$this->initRangeExpr || empty($this->pluginOptions['ranges']) || !is_array($this->pluginOptions['ranges'])) {
return;
}
$range = [];
foreach ($this->pluginOptions['ranges'] as $key => $value) {
if (!is_array($value) || empty($value[0]) || empty($value[1])) {
throw new InvalidConfigException("Invalid settings for pluginOptions['ranges']. Each range value must be a two element array.");
}
$range[$key] = [static::parseJsExpr($value[0]), static::parseJsExpr($value[1])];
}
$this->pluginOptions['ranges'] = $range;
}
There was some othe way?
One more question. How can I setup to have immediatly both rangelist and the two caledar as in the bootstrap example?