title: yii2 Unique Validation(non-ajax) not working
body: <p>I see some links says that Yii2 unique validation is for Ajax validation only(But I dont find any best practice to follow.).So I'm asking this for non ajax validation in Yii2 </p>
  
  <p>my model rules are</p>
  
  <pre><code>['name', 'unique', 'targetAttribute' =&gt; 'function_id','message' =&gt; 'name must be unique.'],
  </code></pre>
  
  <p>My controller functions are normal actionCreate()</p>
  
  <p>Anybody have solution for this? Thanks in Advance</p>
  
  <p>Edit: For Ajax
  ok.I Did,My controller code is now</p>
  
  <pre><code>    $model = new JobFunctionRole();
      $model-&gt;scenario = 'insert';
  
      $jobFunction=JobFunction::find()-&gt;all();
      if(Yii::$app-&gt;request-&gt;post()){
          if (Yii::$app-&gt;request-&gt;isAjax &amp;&amp; $model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
              Yii::$app-&gt;response-&gt;format = Response::FORMAT_JSON;
              return ActiveForm::validate($model);
          }
          if ($model-&gt;save()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;job_function_role_id]);
          }
      } else {
          return $this-&gt;render('create', [
              'model' =&gt; $model,'jobFunction'=&gt;$jobFunction
          ]);
      }`
  </code></pre>
  
  <p>But page redirects and shows blank page.</p>