title: Yii2 - activeform ajax validation with normal form submit
body: <p>Using the <code>beforeSubmit</code> function of <code>yii.activeForm.js</code>, how can I make it perform a normal form submit when validation passes?</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>$('.ajax-form').on('beforeSubmit', function (event) {
      var form = $(this);
      var url = form.attr('action');
      var type = form.attr('method');
      var data = form.serialize();
  
      $.ajax({
          url: url,
          type: type,
          data: data,
          success: function (result) {
              if (result.errors.length != 0) {
                  form.yiiActiveForm('updateMessages', result.errors, true);
              }
              else if (result.confirmed == true) {
                  $('.confirm-panel').show();
              }
              else {
                  return true;
              }
         },
         error: function() {
             alert('Error');
         }
      });
  
      // prevent default form submission
      return false;
  });
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function actionProcess()
  {
      $model = $this-&gt;findModel($id);
  
      if (Yii::$app-&gt;request-&gt;isAjax) {
          $return_array = [
              'errors' =&gt; [],
              'confirmed' =&gt; false,
          ];
  
          Yii::$app-&gt;response-&gt;format = Response::FORMAT_JSON;
          $return_array['errors'] = ActiveForm::validate($model);
  
          if ($model-&gt;confirm == 1) {
              $return_array['confirmed'] = true;
          }
  
          return $this-&gt;asJson($return_array);
      }
  
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
          return $this-&gt;redirect(['success']);
      }
  
      return $this-&gt;render('process', [
          'model' =&gt; $model,
      ]);
  }
  </code></pre>
  
  <p>As you can see I am also trying to return additional data in my AJAX response. The problem I am having is the <code>return true</code> in the ajax success isn't working. I can't seem to break out of the function. I have also tried <code>form.submit()</code> here but this just does a submit loop via AJAX.</p>
  
  <p>By the way I am not using <code>enableAjaxValidation</code> because I have some additional custom validation that happens in my controller. So this is why I have created my own custom handler for this.</p>