S
S
Snewer2016-06-04 20:14:01
Yii
Snewer, 2016-06-04 20:14:01

How to display captcha in Yii2?

Hello!
How can I display captcha with the following template (how to organize such a template):

<div class="form-group">
    <div ... >{image}<div>
</div>
<div class="form-group">
    <label ... >{label}</label>
   <div ... >
        {input}
        {error}
    </div>
</div>

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-06-04
@webinar

The captcha has a widget that has a template property where you need to specify {image} and {input} + your html

<?=\yii\captcha\Captcha::widget([
    'name' => 'captcha',
    'template' => '<div class="form-group">
    <div>{image}<div></div>
<div class="form-group">
{input}
</div>',
]);?>

But the standard yii2 captcha is so dumb that I would look towards using google captcha.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question