I have validation rules for model as follows
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
//post of step 1
if (isset($_POST['yt0']))
{
return array(
array('EmailAddress,', 'required','message' => Yii::t('message', 'USERNAME_REQUIRED')),
array('Password,', 'required','message' => Yii::t('message', 'PASSWORD_REQUIRED')),
array('confirmPassword,', 'required','message' => Yii::t('message', 'CONFIRM_PASSWORD_REQUIRED')),
array('Password','length', 'max' => 100, 'min' => 6, 'tooShort' => Yii::t('message', 'PASSWORD_LENGTH')),
array('confirmPassword', 'compare', 'compareAttribute'=>'Password','message' => Yii::t('message', 'PASSWORD_COMPARE')),
array('EmailId,', 'required','message' => Yii::t('message', 'EMAILID_REQUIRED')),
array('EmailId','email','message'=>Yii::t('message', 'EMAILID_VALID')),
array('chapterCode,', 'required','message' => Yii::t('message', 'CHAPTERCODE_REQUIRED')),
array('verifyCode,', 'required','message' =>Yii::t('message', 'VERIFYCODE_REQUIRED')),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'caseSensitive'=>true,'message' =>Yii::t('message', 'VERIFYCODE_INCORRECT') ),
array('EmailAddress', 'unique','className'=>'User','attributeName'=>'EmailAddress','message'=>Yii::t('message', 'EMAILID_UNIQUE')),
array('PersonId', 'unique','className'=>'User','attributeName'=>'PersonId','message'=>"Person already exists."),
array('FailedLoginCount', 'safe'),
);
} elseif (isset($_POST['yt1']))
{
return array(
array('EmailAddress,', 'required','message' => Yii::t('message', 'USERNAME_REQUIRED')),
array('Password,', 'required','message' => Yii::t('message', 'PASSWORD_REQUIRED')),
array('FailedLoginCount', 'safe'),
);
}elseif (isset($_POST['savecontact'])||$this->memBelongsto==0)
{
return array(
array('EmailAddress,', 'required','message' => Yii::t('message', 'USERNAME_REQUIRED')),
array('Password,', 'required','message' => Yii::t('message', 'PASSWORD_REQUIRED')),
array('confirmPassword', 'required','message' => Yii::t('message', 'CONFIRM_PASSWORD_REQUIRED')),
array('Password','length', 'max' => 100, 'min' => 6,'tooShort' => Yii::t('message', 'PASSWORD_LENGTH')),
array('confirmPassword', 'compare', 'compareAttribute'=>'Password','message' => Yii::t('message', 'PASSWORD_COMPARE')),
array('EmailId,', 'required','message' => Yii::t('message', 'EMAILID_REQUIRED'),'except'=>'datavalid'),
array('EmailId','email','message'=>Yii::t('message', 'EMAILID_VALID'),'except'=>'datavalid'),
array('FailedLoginCount', 'safe'),
);
}else{
return array(
array('EmailAddress,EmailId, Password', 'required'),
array('PersonId, ActiveFlag, FailedLoginCount', 'numerical', 'integerOnly'=>true),
array('EmailAddress, Password', 'length', 'max'=>100),
array('confirmPassword,', 'required','message' => Yii::t('message', 'PASSWORD_REQUIRED')),
array('Password','length', 'max' => 100, 'min' => 6, 'tooShort' => Yii::t('message', 'PASSWORD_LENGTH')),
array('confirmPassword', 'compare', 'compareAttribute'=>'Password','message' => Yii::t('message', 'PASSWORD_COMPARE')),
array('chapterCode,', 'required','message' => Yii::t('message', 'CHAPTERCODE_REQUIRED')),
array('verifyCode,', 'required','message' =>Yii::t('message', 'VERIFYCODE_REQUIRED')),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'caseSensitive'=>true,'message' =>Yii::t('message', 'VERIFYCODE_INCORRECT')),
array('FailedLoginCount', 'safe'),
);
}
}
and here yt0
is name of submit button on signup page and so for signup the rules of yt0
will be applied and I have another form for change password so on that page I need only three fields and the submit button for change password is savecontact
and but savecontact rules are applied but the signup button rules are conflicting so the validation on signup is not working . Is it right way to right rules as above any suggestions please....