I've a question about the Kartik DateRangePicker Widget that i use in my gridview for filter some results.
in my SearchModel i've created two attributes
public $date_start;
public $date_end;
i use these for filter a field in database 'insert_date'.
In my view, as grid configuration, i've set these options
[
'attribute' => 'insert_date',
'options' => ['class' => 'gridview-date-column'],
'filter' => DateRangePicker::widget([
'model' => $searchModel,
'name' => 'insert_date',
'attribute' => 'insert_date',
'startAttribute' => 'date_start',
'endAttribute' => 'date_end',
'convertFormat'=>true,
'pluginOptions' => [
'opens'=>'right',
'locale' => [
'cancelLabel' => 'Clear',
'format' => 'd-m-Y',
],
]
]),
'format' => ['date', Yii::$app->formatter->datetimeFormat],
'contentOptions'=>['style'=>'min-width: 200px;']
],
By default $date_start and $date_end haven't a value, so , when i enter in my view and try to filter this field i get an 'invalidDate' error and a series of NaN on the calendars.
This is fixed if i set a value for these two fields or if remove them from the configuration ( so i can only use insert_date attribute as string with these two ranges for filtering ).
Looking in the plugin repository i've found the same case and as response of the author
This problem occurs because you have an invalid date format for the data that does not match the plugin's format.
But as empty these fields can never have a correct data format.
Someone had the same problem? Thanks in advance for all the responses.