public function rules() { $rules = parent::rules(); /* FIXME: As soon as i grasp how i can dynamically add variables to a class in PHP, i will enable this code snippet for flexibility: $profile = new YumProfile; $profile_rules = $profile->rules(); foreach($profile_rules as $rule) if(isset($rule[0]) && is_string($rule[0])) $this->${$rule[0]} = ''; $rules = array_merge($rules, $profile->rules()); */ $rules[] = array('username', 'required'); $rules[] = array('password, verifyPassword', 'required'); $rules[] = array('password', 'compare', 'compareAttribute'=>'verifyPassword', 'message' => Yum::t("Retype password is incorrect.")); if(Yum::module('registration')->enableCaptcha) $rules[] = array('verifyCode', 'captcha', 'allowEmpty'=>CCaptcha::checkRequirements()); return $rules; }
public function rules() { $rules = parent::rules(); if (!(Yum::hasModule('registration') && Yum::module('registration')->registration_by_email)) { $rules[] = array('username', 'required'); } $rules[] = array('newsletter, terms,type_id', 'safe'); // password requirement is already checked in YumUser model, its sufficient // to check for verifyPassword here $rules[] = array('verifyPassword', 'required'); $rules[] = array('password', 'compare', 'compareAttribute' => 'verifyPassword', 'message' => Yum::t("Retype password is incorrect.")); if (Yum::module('registration')->enableCaptcha && !Yum::module()->debug) { $rules[] = array('verifyCode', 'captcha', 'allowEmpty' => CCaptcha::checkRequirements()); } return $rules; }