Google recaptcha validation in yii2 always fails -


i use himiklab/yii2-recaptcha-widget. validation error when submit form.

{"captcha":["the verification code incorrect."]}. 

form:

$form->field($model, 'captcha',['template' => "{input}\n{hint}\n{error}"])->widget(             \himiklab\yii2\recaptcha\recaptcha::classname(),             [             'sitekey' => <mysitekey>,             'widgetoptions' => ['id'=>'recaptcha1']             ])  

controller:

if(isset($_post['contact'])){             if ($model->load(yii::$app->request->post()) && $model->save()) { 

what doing wrong?

the problem yii run validation twice, on validation() method , during save executes again validation, cause first validation successful second returns error. so, second case need save without running validations, save(false).

the second chance might unhook validation of captcha before safe() method.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -