title: Validate unique field using Ajax, Yii2 ActiveForm
body: <p>I am new to Yii, and cannot figure out how ajax validation works with <code>ActiveForm</code>. 
  In my model I have unique field:</p>
  
  <pre><code>public function rules()
      {
          return [
               //...
              [['end_date'], 'unique'], //ajax is not working 
  
              [   'end_date', //ajax is working
                  'compare',
                  'compareAttribute'=&gt;'start_date',
                  'operator'=&gt;'&gt;=',  
                  'skipOnEmpty'=&gt;true,
                  'message'=&gt;'{attribute} must be greater or equal to "{compareValue}".'
              ],
          ];
      }
  </code></pre>
  
  <p>The compare rule is validated with ajax and works fine, but <code>unique</code> is not. I tried to enable ajax validation on form:</p>
  
  <pre><code>  &lt;?php $form = ActiveForm::begin( ['id' =&gt; 'routingForm', 'enableClientValidation' =&gt; true, 'enableAjaxValidation' =&gt; true]); ?&gt;
  </code></pre>
  
  <p>But don't know what to do next.</p>
  
  <p>Controller:</p>
  
  <pre><code>public function actionCreate()
  {
      $model = new Routing();
      $cities = [];     
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {            
          return $this-&gt;redirect(['index']);
      } else {
          return $this-&gt;renderAjax('create', [
              'model' =&gt; $model,
              'cities' =&gt; $cities
          ]);
      }
  }
  </code></pre>
  
  <p>I know I could make ajax call to controller on <code>end_date</code> change event and form <code>submit</code>, but not sure how make all appropriate css to show the errors.</p>