1

I want to set safe or allow empty captcha on scenario like bellow code.

 public function rules() {
        return [
            [['verifyCode'], 'safe', 'on'=>'admin'],
        ];
    }

But it does not work, and I got this error.

Invalid CAPTCHA action ID: site/captcha

and also this page didn't help me.

Community
  • 1
  • 1
Mohammad Aghayari
  • 1,010
  • 3
  • 15
  • 38

1 Answers1

2

Try this. Add rule:

[['verifyCode'], 'captcha', 'skipOnEmpty' => true, 'on'=>'admin']

In controller, when create instance:

$model->scenario = 'admin';
Vitaly
  • 1,261
  • 2
  • 10
  • 20