title: Yii2 active form, please wait message while submitting with ajax
body: <p>I'm using Yii2's advanced template, and looking for a way to display a dialog with 'Please wait...' message while sending an login form to the server.</p>
  
  <p>Here is my active form code:</p>
  
  <pre><code>            &lt;?php $form = ActiveForm::begin([
                  'id' =&gt; $model-&gt;formName(),
                  'enableAjaxValidation' =&gt; true,
              ]); ?&gt;
                  &lt;fieldset&gt;
  
                      &lt;?= $form-&gt;field($model, 'username', [
                          'inputOptions' =&gt; [
                              'placeholder' =&gt; $model-&gt;getAttributeLabel('username'),
                          ],
                      ])-&gt;label(false); ?&gt;
  
                      &lt;?= $form-&gt;field($model, 'password', [
                          'inputOptions' =&gt; [
                              'placeholder' =&gt; $model-&gt;getAttributeLabel('password'),
                          ],
                      ])-&gt;label(false)-&gt;passwordInput() ?&gt;
  
                      &lt;?= $form-&gt;field($model, 'rememberMe')-&gt;checkbox() ?&gt;
  
                      &lt;?= Html::submitButton('Login', ['class' =&gt; 'btn btn-lg btn-success btn-block', 'name' =&gt; 'login-button']) ?&gt;
                  &lt;/fieldset&gt;
              &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  
  <p>And my server side action:</p>
  
  <pre><code>public function actionLogin()
  {
      if (!\Yii::$app-&gt;user-&gt;isGuest) {
          return $this-&gt;goHome();
      }
  
      $model = new LoginForm();
      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;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;login()) {
          return $this-&gt;goBack();
      } else {
          return $this-&gt;render('login', [
              'model' =&gt; $model,
          ]);
      }
  }
  </code></pre>
  
  <p>I'm successfully validating the inputs / sending the form, but need to display a dialog, so if the connection is slow the user will get an idea that the form is actually sending and needs more time to complete.</p>