title: unique validation is not working in Update case in YII?
body: <p>I have applied unique validation for Employee Code. it is working fine for <strong>Add Emp</strong> case. But i am not getting why it is not working in case of Update, here is the code i have used for this:</p>
  
  <p>My rule method is :</p>
  
  <pre><code>public function rules()
  {
  
      return array(
          array('is_active', 'numerical', 'integerOnly'=&gt;true),
          array('first_name, last_name, employee_code, username, password, role,joining_date,', 'required','on'=&gt;array('create','update')),   
  
          array('employee_code', 'numerical', 'integerOnly'=&gt;true),
  
          array('employee_code', 'unique','on'=&gt;array('create','update')),
          array('employee_code', 'length', 'min' =&gt; 4, 'max'=&gt;4, 'message'=&gt;Yii::t("translation", "{attribute} is too short.")),
          array('username','email'),      
          array('username','valid_username','on'=&gt;array('create')),
          array('username', 'required','on'=&gt;array('forgotPassword')),
  
          array('currentPassword, newPassword, newPasswordRepeat', 'required','on'=&gt;array('change')),
          array('newPassword', 'compare', 'compareAttribute'=&gt;'newPasswordRepeat','on'=&gt;array('change'),'message'=&gt;'New and Confirm Password do not match.'),
          array('verifyCode', 'captcha', 'allowEmpty'=&gt;!CCaptcha::checkRequirements(),'on'=&gt;array('forgotPassword')),
          array('joining_date', 'safe'),
          array('years', '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>Please can someone identify where i am wrong. Please help me.</p>