kartik datepicker daterange default values

i am using the kartik date range widget of the date picker, i would like to set the start and end date ranges to the current month.

Ie, if today is 8th June 2016, i need




    <?= $form->field($model, 'sale_date')->widget(DatePicker::className(), [

        'attribute'      => 'sale_date',

        'value'     => '2016-06-01',

        'type'      => DatePicker::TYPE_RANGE,

        'attribute2'     => 'sale_date',

        'value2'    => '2016-06-30',

        'pluginOptions' => [

            'autoclose' => true,

            'format' => 'yyyy/mm/dd'

        ]

    ]); ?>



Can I do values dynamically ?

Edit:

I also just noticed when i pick the dates as above with the widget, for some reason, the first value keeps resetting itself to the same as the second value and i end up with ‘2016/06/30’ to ‘2016/06/30’ :blink:

thx

Hi

Maybe you could use it as folows.




<?= $form->field($model, 'fechainicial')->widget(DateRangePicker::className(), [

        'attributeTo' => 'fechafinal', 

        'form' => $form, // best for correct client validation

        'language' => 'es',

        'size' => 'md',

        'clientOptions' => [

            'autoclose' => true,

            'format' => 'yyyy-mm-dd',

            'startDate' => $startFecha,

            'endDate' => $endFecha,

          ]

]);?>



you only need to define the values for


 $starFecha 

and


 $endFecha 

.

regards,