我已经为员工代码应用了唯一验证。它适用于Add Emp案例。但我不明白为什么它在更新的情况下不起作用,这是我用于此的代码:
我的规则方法是:
public function rules()
{
return array(
array('is_active', 'numerical', 'integerOnly'=>true),
array('first_name, last_name, employee_code, username, password, role,joining_date,', 'required','on'=>array('create','update')),
array('employee_code', 'numerical', 'integerOnly'=>true),
array('employee_code', 'unique','on'=>array('create','update')),
array('employee_code', 'length', 'min' => 4, 'max'=>4, 'message'=>Yii::t("translation", "{attribute} is too short.")),
array('username','email'),
array('username','valid_username','on'=>array('create')),
array('username', 'required','on'=>array('forgotPassword')),
array('currentPassword, newPassword, newPasswordRepeat', 'required','on'=>array('change')),
array('newPassword', 'compare', 'compareAttribute'=>'newPasswordRepeat','on'=>array('change'),'message'=>'New and Confirm Password do not match.'),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>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'=>'search'),
);
请有人能指出我错在哪里。请帮我。