Difference between #201 and #202 of
Yii v2 snippet guide

Revision #202 has been created by rackycz on Jun 30, 2020, 10:41:16 PM with the memo:

GridView + DatePicker
« previous (#201) next (#203) »

Changes

Title unchanged

Yii v2 snippet guide

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
```php
function getDatepickerFilter($searchModel, $attribute) {
$name = basename(get_class($searchModel)) . "[$attribute]";
$result = \yii\jui\DatePicker::widget(['language' => 'en', 'dateFormat' => 'php:Y-m-d', 'name'=>$name, 'value'=>$searchModel->$attribute, 'options' => ['class' => 'form-control'] ]);
  if (trim($searchModel->$attribute)!=='') {     $result = '<div style="display:flex;flex-direction:column">' . $result     . '<div class="btn btn-danger btn-xs glyphicon glyphicon-remove" onclick="$(this).prev(\'input\').val(\'\').trigger(\'change\')"></div></div>';   }   return $result; } // ...     <?= GridView::widget([        'dataProvider' => $dataProvider,        'filterModel' => $searchModel,        'columns' => [        // ...        [
 
          
[
 
'attribute' => 'myDateCol',            'value' => 'myDateCol',    'label'=>'My date label',            'filter' => getDatepickerFilter($searchModel,'myDateCol'),    'format' => 'html'            ],        // ... ```
7 0
4 followers
Viewed: 254 394 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: 5 months ago
Update Article

Revisions

View all history