Answer the question
In order to leave comments, you need to log in
How to properly set Yii2 FieldRange in GridView?
Good day colleagues!
For a long time I can’t make friends with GridView FieldRange from Kartik.
If you make one selection field in turn through DatePicker , there are no problems.
The essence of the problem:
When I select the first date, the form data is cleared and no filtering occurs, but I do not see that these values have been transferred to the server. More precisely, they are passed to the DateControl:
Code:
<?php
[
'attribute' => 'update_at',
'format' => ['date', 'dd.MM.Y H:i:s'],
'value' => 'update_at',
'contentOptions' => ['class' => 'text-center'],
'filter' => FieldRange::widget([
'model' => $searchModel,
'template' => '{widget}{error}',
'attribute1' => 'date_from',
'attribute2' => 'date_to',
'type' => FieldRange::INPUT_WIDGET,
'widgetClass' => DateControl::classname(),
'widgetOptions1' => [
'saveFormat' => 'php:Y-m-d'
],
'widgetOptions2' => [
'saveFormat' => 'php:Y-m-d'
],
]),
],
Answer the question
In order to leave comments, you need to log in
Specifically, I did not come across FieldRange , because there is a similar functionality in the DatePicker itself :
'filter' => DatePicker::widget([
'model' => $searchModel,
'attribute' => 'created_start',
'attribute2' => 'created_end',
'separator' => '-',
'type' => DatePicker::TYPE_RANGE,
'pluginOptions' => ['format' => 'yyyy-mm-dd'],
'options' => ['autocomplete' => 'off'],
'options2' => ['autocomplete' => 'off'],
]),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question