captcha yii2 yii2-advanced-app

recaptcha admin



Yii2 ID de acción de CAPTCHA inválida en el módulo (1)

Debe modificar su regla de validación:

[''verifyCode'', ''captcha'',''captchaAction''=>''/contactus/default/captcha''],

Obtengo la Excepción de ID de acción CAPTCHA Invalid en mi módulo de contacto personalizado. Logré mostrar el captcha pero la regla de validación de modelos arroja la excepción de ID de acción no válida. A continuación está mi código:

contactus / controllers / DefaultController.php

class DefaultController extends Controller { public function behaviors() { return [ ''access'' => [ ''class'' => /yii/filters/AccessControl::className(), ''rules'' => [ [ ''actions'' => [''captcha'',''index''], ''allow'' => true, ], ] ] ]; } public function actions() { return [ ''error'' => [ ''class'' => ''yii/web/ErrorAction'', ], ''captcha'' => [ ''class'' => ''yii/captcha/CaptchaAction'', ''fixedVerifyCode'' => YII_ENV_TEST ? ''testme'' : null, ], ]; } public function actionIndex() { $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->contact(setting::ADMIN_EMAIL_ADDRESS)) { Yii::$app->session->setFlash(''contactFormSubmitted''); return $this->refresh(); } else { return $this->render(''index'', [ ''model'' => $model, ]); } } }

contactus / models / ContactForm.php

public function rules() { return [ // name, email, subject and body are required [[''name'', ''email'', ''subject'', ''body'',''verifyCode''], ''required''], // email has to be a valid email address [''email'', ''email''], // verifyCode needs to be entered correctly [''verifyCode'', ''captcha'',''captchaAction''=>''default/captcha''], ]; }

contactus / views / default / index.php

<?php $form = ActiveForm::begin([''id'' => ''contact-form'']); ?> <?= $form->field($model, ''name'') ?> <?= $form->field($model, ''email'') ?> <?= $form->field($model, ''subject'') ?> <?= $form->field($model, ''body'')->textArea([''rows'' => 6]) ?> <?= $form->field($model, ''verifyCode'')->widget(Captcha::className(), [ ''captchaAction'' => ''default/captcha'', ''template'' => ''<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'', ]) ?> <div class="form-group"> <?= Html::submitButton(''Submit'', [''class'' => ''btn btn-primary'', ''name'' => ''contact-button'']) ?> </div> <?php ActiveForm::end(); ?>

Me sale el siguiente error:

Exception (Invalid Configuration) ''yii/base/InvalidConfigException'' with message ''Invalid CAPTCHA action ID: default/captcha''in E:/wamp/www/yii-application/vendor/yiisoft/yii2/captcha/CaptchaValidator.php:81

¿Me estoy perdiendo de algo?