나는 Employee Code에 대해 고유 한 유효성 검증을 적용했습니다. 엠페셜 케이스를 추가해도 문제가 없습니다.YII의 업데이트 케이스에서 고유 유효성 검사가 작동하지 않습니까?
내 규칙 방법은 다음과 같습니다 : 내가 잘못 곳
이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'),
);
사람이 식별 할 수 바랍니다하지만이 업데이트의 경우에는 작동하지 않는 이유는 점점 아니에요, 여기 내가이 사용했던 코드입니다. 도와주세요.
[기본 시나리오 이름] (http://www.yiiframework.com/wiki/266/understanding-scenarios/#hh2)은'insert','update','search'이며'create' 시나리오는 없습니다 . 글쎄, 당신이 수동으로 지정하지 않는 한. –
업데이트로 작동하지 않는다고 말씀 하셨다면 어떻게됩니까? 그것이 유효하지 않습니까? 오류가 있습니까? 컨트롤러 코드를 보여줄 수 있습니까? – Pitchinnate