Answer the question
In order to leave comments, you need to log in
How to work with reCaptcha in scripts in yii2?
I have scripts (validations), and everything works well (regarding other fields),
but the captcha still works for the 'body' script
public $reCaptcha;
public function rules()
{
return [
[['types_pub','subj','name','email','body'], 'required'],
[['email',], 'email'],
[['types_pub','created_at',], 'integer'],
[['is_new',], 'boolean'],
[['subj','name','email'],'string','length'=>[4,32]],
[['body',], 'string','length'=>[10,1024]],
[['reCaptcha'], ReCaptchaValidator::className(), Yii::$app->params['common']['view']['form']['reCaptcha']['key_Secret'] => Yii::$app->params['common']['view']['form']['reCaptcha']['value_Secret']],
];
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['common'] = [
'types_pub','subj','name','body','email', 'reCaptcha'
];
$scenarios['body'] = [
'body'
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question