A
A
Alexey2020-02-06 08:22:58
Yii
Alexey, 2020-02-06 08:22:58

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:
5e3ba1bc98160727555781.png

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'
                    ],
                ]),
               
            ],


Has anyone had experience with this thing and can you tell me what I'm doing wrong?
P/S fields in datetime DB

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2020-02-06
@kuliev_a

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 question

Ask a Question

731 491 924 answers to any question