title: Filter setup for related model in GridView
body: <p>I am trying to setup the filter for related model in Yii2's <a href="http://www.yiiframework.com/doc-2.0/yii-grid-gridview.html" rel="nofollow noreferrer">GridView</a> widget, but I am keep getting the error like the filter value must be an integer.</p>
  
  <p>I have followed <a href="https://stackoverflow.com/questions/21992687/php-yii2-gridview-filtering-on-relational-value/">this question</a>. Now, I have a two models <code>Services.php</code> and <code>ServiceCharge.php</code>.</p>
  
  <p>In <code>ServiceCharge.php</code> the relation is setup like:</p>
  
  <pre><code>public function getServiceName()
      {
          return $this-&gt;hasOne(Services::className(),['id'=&gt;'service_name']);
      }
  </code></pre>
  
  <p>In the <code>ServiceChargeSearch.php</code> the code is like this:</p>
  
  <pre><code>&lt;?php
  
  namespace app\models;
  
  use Yii;
  use yii\base\Model;
  use yii\data\ActiveDataProvider;
  use app\models\ServiceCharges;
  
  /**
   * ServiceChargesSearch represents the model behind the search form about `app\models\ServiceCharges`.
   */
  class ServiceChargesSearch extends ServiceCharges
  {
      /**
       * @inheritdoc
       */
      public function attributes()
      {
          // add related fields to searchable attributes
        return array_merge(parent::attributes(), ['serviceName.services']);
  
      }
      public function rules()
      {
          return [
              [['id'], 'integer'],
              [['charges_cash', 'charges_cashless'], 'number'],
              [['id', 'serviceName.services', 'room_category'], 'safe'],
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function scenarios()
      {
          // bypass scenarios() implementation in the parent class
          return Model::scenarios();
      }
  
      /**
       * Creates data provider instance with search query applied
       *
       * @param array $params
       *
       * @return ActiveDataProvider
       */
      public function search($params)
      {
          $query = ServiceCharges::find();
  
          $dataProvider = new ActiveDataProvider([
              'query' =&gt; $query,
          ]);
          $dataProvider-&gt;sort-&gt;attributes['serviceName.services'] = [
          'asc' =&gt; ['serviceName.services' =&gt; SORT_ASC],
          'desc' =&gt; ['serviceName.services' =&gt; SORT_DESC],
          ];
  
  $query-&gt;joinWith(['serviceName']); 
  
          $this-&gt;load($params);
  
          if (!$this-&gt;validate()) {
              // uncomment the following line if you do not want to any records when validation fails
              // $query-&gt;where('0=1');
              return $dataProvider;
          }
  
          $query-&gt;andFilterWhere([
              'id' =&gt; $this-&gt;id,
             // 'service_name' =&gt; $this-&gt;service_name,
              'room_category' =&gt; $this-&gt;room_category,
              'charges_cash' =&gt; $this-&gt;charges_cash,
              'charges_cashless' =&gt; $this-&gt;charges_cashless,
          ])
        -&gt;andFilterWhere(['LIKE', 'serviceName.services', $this-&gt;getAttribute('serviceName.services')]);
  
          return $dataProvider;
      }
  }
  </code></pre>
  
  <p>and in my Gridview it is setup like this:</p>
  
  <pre><code>[
                  'attribute'=&gt;'service_name',
                  'value'=&gt;'serviceName.services',
  
              ],
  </code></pre>
  
  <p>Which is showing the services name from the related model correctly.</p>
  
  <p>I am not able to see what I am doing wrong, but the filter field for the attribute for service is not showing at all.</p>