Problem in using \kartik\widgets\DateRangePicker for GridView filtering


I’m trying to use DateRangePicker for GridView filtering. At first I tried from scratch this way:

    'filter' => DateRangePicker::widget([

        'model' => $searchModel,

        'autoUpdateOnInit' => false,

        'attribute' => 'data_pubblicazione', // <-- this is the real attribute to be filtered

        'convertFormat' => true,

        'startAttribute' => 'data_iniziale_ricerca_push', // <-- these are splitted attrs

        'endAttribute' => 'data_finale_ricerca_push',

        'pluginOptions' => [

            'locale' => [

                'format' => 'Y-m-d'


            'opens' => 'left',

            'ranges' => [

                "Questo mese" => ["moment().startOf('month')", "moment().endOf('month')"],

                "Mese prossimo" => ["moment().add(1, 'month').startOf('month')", "moment().add(1, 'month').endOf('month')"],




This works fine, except when the grid is initialized. The input field contains just - , and when I click on it the picker pops up with a Custom range and every day is set to NaN:



I think this happens because being the filter fields empty the input is set to that string which is translated to an unknown date.

So I found I could use \kartik\grid\GridView which implements filterType, and I did it this way:

    'attribute' => 'data_pubblicazione',

    'filterType'=> GridView::FILTER_DATE_RANGE,

    'filterWidgetOptions' => [

        'startAttribute' => 'data_iniziale_ricerca_push',

        'endAttribute' => 'data_finale_ricerca_push',

        'presetDropdown' => true,

        'pluginOptions' => [

            'format' => 'YYYY-MM-DD',

            'opens' => 'left',



but this doesn’t seem to work at all, filter is disabled on the column.

What am I doing wrong?