我有以下规则和方案
public function rules(){ return [ [['name','email','password'],'required'],['email','myvalidation'],'email'],[['name','required','on' => 'register'],]; } public function scenarios() { $scenarios = parent::scenarios(); $scenarios['login'] = ['name','password','email'];//Scenario Values Only Accepted return $scenarios; }
我希望规则’myvalidation’仅应用于登录场景,而不是在其他情况下应用.如何在Yii2中实现?