title: Yii2: Either one field is required Validation
body: <p>I have to implement the validation as mentioned in the title that either one of the two fields (email, phone) is required. I am doing this in my <code>model</code>:</p>
  
  <pre><code>[['email'],'either', ['other' =&gt; ['phone']]],
  </code></pre>
  
  <p>And this is the method:</p>
  
  <pre><code> public function either($attribute_name, $params) {
          $field1 = $this-&gt;getAttributeLabel($attribute_name);
          $field2 = $this-&gt;getAttributeLabel($params['other']);
          if (empty($this-&gt;$attribute_name) &amp;&amp; empty($this-&gt;$params['other'])) {
              $this-&gt;addError($attribute_name, Yii::t('user', "either {$field1} or {$field2} is required."));
              return false;
          }
          return true;
      }
  </code></pre>
  
  <p>When I access my index page, it gives me this error:</p>
  
  <blockquote>
    <p>Exception (Unknown Property) 'yii\base\UnknownPropertyException' with
    message 'Setting unknown property: yii\validators\InlineValidator::0'</p>
  </blockquote>
  
  <p>Any help?</p>