title: Yii2 datepicker in kartik gridview not working
body: <p>I'm using <a href="http://demos.krajee.com/grid-demo" rel="nofollow noreferrer">kartik gridview</a> and I want to add a <a href="http://demos.krajee.com/widget-details/datepicker" rel="nofollow noreferrer">datepicker</a> to the search fields
  I'm also using <a href="http://demos.krajee.com/datecontrol" rel="nofollow noreferrer">datecontrol</a></p>
  
  <p>This is what I got, but the validation is not working:</p>
  
  <p>Gridview date picker:</p>
  
  <pre><code>        [
              'attribute'=&gt;'date',
              'value' =&gt; function ($model, $index, $widget) {
                  return Yii::$app-&gt;formatter-&gt;asDate($model-&gt;date);
              },
              'filterType' =&gt; GridView::FILTER_DATE,
              'filterWidgetOptions' =&gt; [
                  'pluginOptions' =&gt; [
                      'format' =&gt; 'dd-mm-yyyy',
                      'autoclose' =&gt; true,
                      'todayHighlight' =&gt; true,
                  ]
              ],
              'width' =&gt; '160px',
              'hAlign' =&gt; 'center',
          ],
  </code></pre>
  
  <p>Datecontrol settings:</p>
  
  <pre><code>    'datecontrol' =&gt;  [
          'class' =&gt; 'kartik\datecontrol\Module',
  
          // format settings for displaying each date attribute (ICU format example)
          'displaySettings' =&gt; [
              Module::FORMAT_DATE =&gt; 'php:d-m-Y',
              Module::FORMAT_TIME =&gt; 'php:H:m:s a',
              Module::FORMAT_DATETIME =&gt; 'dd-MM-yyyy HH:mm:ss a',
          ],
  
          // format settings for saving each date attribute (PHP format example)
          'saveSettings' =&gt; [
              Module::FORMAT_DATE =&gt; 'php:U', // saves as unix timestamp
              Module::FORMAT_TIME =&gt; 'php:H:i:s',
              Module::FORMAT_DATETIME =&gt; 'php:Y-m-d H:i:s',
          ],
  
          // set your display timezone
          'displayTimezone' =&gt; 'Europe/Brussels',
  
          // set your timezone for date saved to db
          'saveTimezone' =&gt; 'Europe/Brussels',
  
          // automatically use kartik\widgets for each of the above formats
          'autoWidget' =&gt; true,
  
          // default settings for each widget from kartik\widgets used when autoWidget is true
          'autoWidgetSettings' =&gt; [
              Module::FORMAT_DATE =&gt; ['pluginOptions' =&gt; [
                  'autoclose' =&gt; true,
                  'todayHighlight' =&gt; true,
                  //'todayBtn' =&gt; true
              ]],
              Module::FORMAT_DATETIME =&gt; [], // setup if needed
              Module::FORMAT_TIME =&gt; [], // setup if needed
          ],
          // Use custom convert action
          'convertAction' =&gt; '/cms/parse/convert-date-control'
      ],
  </code></pre>
  
  <p>Searchmodel:</p>
  
  <pre><code>&lt;?php
  
  namespace infoweb\news\models;
  
  use Yii;
  use yii\base\Model;
  use yii\data\ActiveDataProvider;
  
  /**
   * NewsSearch represents the model behind the search form about `infoweb\empoyees\models\News`.
   */
  class NewsSearch extends News
  {
  /**
   * @inheritdoc
   */
  public function rules()
  {
      return [
          [['active'], 'integer'],
          [['title', 'date'], 'safe'],
      ];
  }
  
  /**
   * @inheritdoc
   */
  public function scenarios()
  {
      // bypass scenarios() implementation in the parent class
      return Model::scenarios();
  }
  
  /**
   * Creates data provider instance with search query applied
   * @return ActiveDataProvider
   */
  public function search($params)
  {
  
      // Transform the date to a unix timestamp for usage in the search query
      if (isset($params['NewsSearch']['date'])) {
          $origDate = $params['NewsSearch']['date'];
          $params['NewsSearch']['date'] = strtotime($params['NewsSearch']['date']);
      }
  
      $query = News::find();
  
      $query-&gt;andFilterWhere(['language' =&gt; Yii::$app-&gt;language]);
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
          'sort' =&gt; ['defaultOrder' =&gt; ['date' =&gt; SORT_ASC]],
          'pagination' =&gt; [
              'pageSize' =&gt; 50,
          ],
      ]);
  
      // Join the entity model as a relation
      $query-&gt;joinWith(['translations']);
  
      // enable sorting for the related column
      $dataProvider-&gt;sort-&gt;attributes['title'] = [
          'asc' =&gt; ['title' =&gt; SORT_ASC],
          'desc' =&gt; ['title' =&gt; SORT_DESC],
      ];
  
      if (!($this-&gt;load($params) &amp;&amp; $this-&gt;validate())) {
          return $dataProvider;
      }
  
      $query-&gt;andFilterWhere([
          'id' =&gt; $this-&gt;id,
          'date' =&gt; $this-&gt;date,
          'active' =&gt; $this-&gt;active,
          'created_at' =&gt; $this-&gt;created_at,
          'updated_at' =&gt; $this-&gt;updated_at,
      ]);
  
      $query-&gt;andFilterWhere(['like', 'title', $this-&gt;title]);
  
      // Format the date for display
      if (isset($params['NewsSearch']['date'])) {
          $this-&gt;date = $origDate;
      }
  
      return $dataProvider;
  }
  }
  </code></pre>
  
  <p>Screen:</p>
  
  <p><img src="https://i.stack.imgur.com/Xlo86.jpg" alt="Date field validation is wrong"></p>