Commits

Jacob Moen  committed fa42c9e

Two small fixes to login form

  • Participants
  • Parent commits 3139ddb

Comments (0)

Files changed (2)

File protected/modules/user/controllers/LoginController.php

 	{
 		if (Yii::app()->user->isGuest) {
 			$model=new UserLogin;
+
+	        $this->performAjaxValidation($model);
+
 			// collect user input data
 			if(isset($_POST['UserLogin']))
 			{
 		$lastVisit->save();
 	}
 
+    /**
+     * Performs the AJAX validation.
+     * @param CModel the model to be validated
+     */
+    protected function performAjaxValidation($model)
+    {
+        if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
+        {
+            echo CActiveForm::validate($model);
+            Yii::app()->end();
+        }
+    }
 }

File protected/modules/user/views/user/login.php

         <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
         'type'=>'inline',
         'enableClientValidation' => true,
+        'id' => 'login-form',
         'clientOptions'=>array('validateOnSubmit'=>true),
-        'errorMessageCssClass'=>'error',
+        //'errorMessageCssClass'=>'error',
         'htmlOptions'=>array('class'=>'well'),
         )); ?>
         <fieldset>
             <legend>Login</legend>
         </fieldset>
+    <?php echo $form->errorSummary($model); ?>
         <div class="row-fluid">
             <div class="span12">
                 <?php echo $form->error($model,'username'); ?>