title: Validation Rules are not working for change password in Yii php?
body: <p>I am creating change password functionality, all things are working fine except the old password validation rule.here is my code</p>
  
  <pre><code>public function rules()
  {
      return array(
          array('is_active', 'numerical', 'integerOnly'=&gt;true),
          array('first_name, joining_date,last_name, employee_code, username, password, role', 'required','on'=&gt;array('create')),     
          array('employee_code', 'numerical', 'integerOnly'=&gt;true),
          array('username','email'),      
          array('username','valid_username','on'=&gt;array('create')),
  
          //array('username', 'contraints', 'readOnly'=&gt;true, 'on'=&gt;'update'),
  
          array('currentPassword, newPassword, newPasswordRepeat', 'required','on'=&gt;array('change')),
          //array('newPassword', 'length', 'min' =&gt; 6, 'max'=&gt;20, 'message'=&gt;Yii::t("translation", "{attribute} is too short.")),
          //array('newPassword','ext.SPasswordValidator.SPasswordValidator', 'preset' =&gt; 'strong', 'max' =&gt; 41),
          array('newPassword', 'compare', 'compareAttribute'=&gt;'newPasswordRepeat','on'=&gt;array('change')),
  
          array('currentPassword', 'equalPasswords','on'=&gt;array('change')),
  
          array('verifyCode', 'captcha', 'allowEmpty'=&gt;!CCaptcha::checkRequirements(),'on'=&gt;array('forgotPassword')),
          array('joining_date', 'safe'),
          array('user_id, first_name, last_name, employee_code, username, password, role, joining_date, pending_regular_leave, pending_medical_leave, allocated_regular_leave, allocated_medical_leave, is_active', 'safe', 'on'=&gt;'search'),
      );
  }
  </code></pre>
  
  <p>My change password function is </p>
  
  <pre><code>public function equalPasswords($attribute, $params)
  {
      $user = Users::model()-&gt;findByPk(Yii::app()-&gt;user-&gt;id); 
      if ($user-&gt;password != md5($attribute))
      {
         $this-&gt;addError($attribute, 'Old password is incorrect.');
      }   
  }
  </code></pre>
  
  <p><strong>Update method</strong></p>
  
  <p>:</p>
  
  <pre><code>public function actionChange()
  {
          $model=new Users;
          $model-&gt;setScenario('change');
  
      if (isset($_POST['Users'])) {
          $model-&gt;setAttributes($_POST['Users']);                     
          if($model-&gt;validate())
              {       
                  $pass = md5($_POST['Users']['newPassword']);            
                  $userModel = Users::model()-&gt;findByPk(Yii::app()-&gt;user-&gt;id);
                  $userModel-&gt;password = $pass; 
                  $data = $userModel-&gt;update();
                  Yii::app()-&gt;user-&gt;setFlash('success',"Password changed successfully!");
              }
          }
  
  $this-&gt;render('change_password', array('model'=&gt;$model,true));
  }
  </code></pre>
  
  <p>when i try to change password with all the correct parameters (correct old password,new password,retype password) it update the password but also shows me error that your <strong>old password does not correct</strong> .please help me to resolve this as i am new to Yii. 
  Thanks in advanced.</p>