Open terabytesoftw opened 6 years ago
Q | A |
---|---|
Yii version | 3.0 |
Yii Captcha version | 3.0 |
PHP version | 7.1.17 |
Operating system | Centos 7 |
@terabytesoftw how did you configure the Captcha ?
In the view:
<?php
use yii\bootstrap4\ActiveForm;
use yii\captcha\Captcha;
use yii\helpers\Html;
<?= $form->field($model, 'verifyCode', [
'labelOptions' => ['id' => 'verifyCode'],
])->widget(Captcha::class, [
'template' => '{input}<div class="text-center">' . '<b>' .
$this->app->t('basic', 'Captcha Code') . ':' . '</b>' . '{image}</div>',
'options' => [
'class' => 'form-control',
'oninput' => 'this.setCustomValidity("")',
'oninvalid' => 'this.setCustomValidity("' . $this->app->t('basic', 'Enter Captcha Code Here') . '")',
'placeholder' => $this->app->t('basic', 'Captcha Code'),
'required' => true,
'style' => 'margin-bottom:10px',
'tabindex' => '5',
],
])->label('<b>' . $this->app->t('basic', 'Captcha Code') . '</b>') ?>
In the model:
public function rules()
{
return [
// verifyCode needs to be entered correctly
['verifyCode', \yii\captcha\CaptchaValidator::class],
];
}