title: Yii Framework Unable to Print Error Message after login attempt failure
body: <p>Hi i am unable to print error message in yii after login attempt failure , Below is the code of my controller , view , loginform (model) and UserIdentity class invloved in login .
  First here is code of controller</p>
  
  <pre><code>public function actionLogin() {
      $model = new LoginForm();
      // if it is ajax validation request
      if (isset($_POST['ajax']) &amp;&amp; $_POST['ajax'] === 'login-form') {
          echo CActiveForm::validate($model);
          Yii::app()-&gt;end();
      }
      // collect user input data
      if (isset($_POST['LoginForm'])) {
          $model-&gt;attributes = $_POST['LoginForm'];
          // validate user input and redirect to the previous page if valid
          if ($model-&gt;validate() &amp;&amp; $model-&gt;login())
              $this-&gt;redirect(array('site/index'));
      }
      // display the login form
      $this-&gt;render('login', array('model' =&gt; $model));
  }
  </code></pre>
  
  <p>after controller i have following code in my view file</p>
  
  <pre><code>&lt;?php
              $form = $this-&gt;beginWidget('CActiveForm', array(
                  'id' =&gt; 'login-form',
                  'enableAjaxValidation' =&gt; true,
                  'enableClientValidation' =&gt; true,
                  'clientOptions' =&gt; array(
                      'validateOnSubmit' =&gt; true,
                  ),
                  'htmlOptions' =&gt; array(
                      'id' =&gt; 'form-contact'
                  ),
              ));
              echo CHtml::errorSummary($model);
              ?&gt;
              &lt;div id="form-left"&gt;
                  &lt;label for="text-email"&gt;Email(&lt;span style="color: red;"&gt;*&lt;/span&gt;)&lt;/label&gt;&lt;br /&gt;
                  &lt;?php echo $form-&gt;textField($model, 'email', array('class' =&gt; 'input')); ?&gt;&lt;br /&gt;
                  &lt;label for="text-password"&gt;Password (&lt;span style="color: red;"&gt;*&lt;/span&gt;)&lt;/label&gt;&lt;br /&gt;
                  &lt;?php echo $form-&gt;passwordField($model, 'password', array('class' =&gt; 'input')); ?&gt;&lt;br /&gt;
                  &lt;br&gt;
                  &lt;?php echo CHtml::submitButton('Login', array('class' =&gt; 'button', 'style' =&gt; 'margin-bottom:50px;')); ?&gt;
              &lt;/div&gt;
              &lt;?php $this-&gt;endWidget(); ?&gt;
  </code></pre>
  
  <p>Here is code of Login Form Model</p>
  
  <pre><code>&lt;?php
  
  /**
   * LoginForm.php
   *
   * @author: antonio ramirez &lt;antonio@clevertech.biz&gt;
   * Date: 7/22/12
   * Time: 8:37 PM
   */
  class LoginForm extends CFormModel {
  
      public $email;
      public $password;
      private $_identity;
      private $_user = null;
  
      /**
       * Model rules
       * @return array
       */
      public function rules() {
          return array(
              array('password, email', 'required'),
              array('password', 'authenticate'),
          );
      }
  
      /**
       * Returns attribute labels
       * @return array
       */
      public function attributeLabels() {
          return array(
              'email' =&gt; Yii::t('labels', 'E-mail'),
              'password' =&gt; Yii::t('labels', 'Password'),
          );
      }
  
      /**
       * Authenticates user input against DB
       * @param $attribute
       * @param $params
       */
      public function authenticate($attribute, $params) {
          $this-&gt;_identity = new UserIdentity($this-&gt;email, $this-&gt;password);
          if (!$this-&gt;_identity-&gt;authenticate())
              $this-&gt;addError('password', 'Incorrect email or password.');
      }
  
      /**
       * Login
       * @return bool
       */
      public function login() {
  
          if ($this-&gt;_identity === null) {
              $this-&gt;_identity = new UserIdentity($this-&gt;email, $this-&gt;password);
              $this-&gt;_identity-&gt;authenticate();
          }
          if ($this-&gt;_identity-&gt;errorCode === UserIdentity::ERROR_NONE) {
              return true;
          }
      }
  
      /**
       * Returns
       * @return null
       */
      public function getUser() {
          if ($this-&gt;_user === null) {
              $attribute = strpos($this-&gt;email, '@') ? 'email' : 'email';
              $this-&gt;_user = User::model()-&gt;find(array('condition' =&gt; $attribute . '=:loginname', 'params' =&gt; array(':loginname' =&gt; $this-&gt;email)));
          }
          return $this-&gt;_user;
      }
  
  }
  </code></pre>
  
  <p>here is my user identity</p>
  
  <pre><code>&lt;?php
  
  class UserIdentity extends CUserIdentity {
  
      private $_id;
  
      public function authenticate() {
          $user = User::model()-&gt;findByAttributes(array('email' =&gt; $this-&gt;username));
          if ($user === null) {
              $this-&gt;errorCode = self::ERROR_USERNAME_INVALID;
          } else if ($user-&gt;password !== md5($this-&gt;password)) {
              $this-&gt;errorCode = self::ERROR_PASSWORD_INVALID;
          } else {
              $this-&gt;_id = $user-&gt;id;
              $this-&gt;errorCode = self::ERROR_NONE;
          }
          return $this-&gt;errorCode;
      }
  
      public function getId() {
          return $this-&gt;_id;
      }
  
  }
  </code></pre>