kartik-v / yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
http://demos.krajee.com/date-range
Other
93 stars 81 forks source link

Using ranges and alwaysShowCalendars #66

Closed nicomollet closed 8 years ago

nicomollet commented 8 years ago

Hello

I am using the DateRangePicker widget in an activeform, working great except when I want to display the ranges while still displaying the calendars. The setting "alwaysShowCalendars" doesn't have any effect.

This example is working as expected displaying the calendars and no ranges:

<?php
echo $form->field( $model, 'date_range', [
'options' => [ 'class'=>'form-group', 'autocomplete' => 'off' ]
] )->widget( DateRangePicker::classname(), [
] );
?>

This example is not working as expected, only displaying the ranges, the "alwaysShowCalendars" setting should force calendars to be displayed:

<?php
echo $form->field( $model, 'date_range', [
'options' => [ 'class'=>'form-group', 'autocomplete' => 'off' ] 
] )->widget( DateRangePicker::classname(), [
    'pluginOptions' => [
        'ranges' => [
            Yii::t('kvdrp', "Today") => ["moment().startOf('day')", "moment()"],
            Yii::t('kvdrp', "Yesterday") => ["moment().startOf('day').subtract(1,'days')", "moment().endOf('day').subtract(1,'days')"],
            Yii::t('kvdrp', "Next {n} Days", ['n' => 7]) => ["moment()", "moment().startOf('day').add(6, 'days')"],
            Yii::t('kvdrp', "Last {n} Days", ['n' => 30]) => ["moment().startOf('day').subtract(29, 'days')", "moment()"],
            Yii::t('kvdrp', "This Month") => ["moment().startOf('month')", "moment().endOf('month')"],
            Yii::t('kvdrp', "Last Month") => ["moment().subtract(1, 'month').startOf('month')", "moment().subtract(1, 'month').endOf('month')"],
        ],
        'alwaysShowCalendars' => true,
    ]
] );
?>

I tried adding initRangeExpr=true and presetDropdown=true without success.

Is there something I need to know or a bug? Thanks a lot.

nicomollet commented 8 years ago

Sorry I see this option has been added recently. (2.1.19).

kartik-v commented 8 years ago

Refer updated assets via #68.