Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
systems:yii2:email_tools [2018/05/10 17:15] smayr [Setup Captcha] |
systems:yii2:email_tools [2018/05/14 11:08] (current) smayr [Setup Captcha] |
<?= $form->field($model, 'subject') ?> | <?= $form->field($model, 'subject') ?> |
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?> | <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?> |
<!-- // To regenerate new captcha after each refresh, call getVerifyCode(). | |
// See: http://www.yiiframework.com/forum/index.php/topic/17638-captcha-code-not-changing | <?php |
--> | // To regenerate new captcha after each refresh, call getVerifyCode(). |
<?php $this->context->createAction('captcha')->getVerifyCode(true) ?> | // See: http://www.yiiframework.com/forum/index.php/topic/17638-captcha-code-not-changing |
| $this->context->createAction('captcha')->getVerifyCode(true); |
| ?> |
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ | <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ |
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', | 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', |
| |
== Setup Captcha == | == Setup Captcha == |
| |
| ''CaptchaAction'' requires either GD2 extension or ImageMagick PHP extension. Check that it meets this requirement. |
| |
In controller's function ''behaviors()'', add ''captcha'' to ''actions'' for user group that requires the use ot if: | In controller's function ''behaviors()'', add ''captcha'' to ''actions'' for user group that requires the use ot if: |
?> | ?> |
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ | <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ |
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', | 'captchaAction' => 'site/captcha', // redirect to correct controller where captcha is defined |
| 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', |
]) ?> | ]) ?> |
</code> | </code> |
| |
| See more: |
| * [[https://www.yiiframework.com/doc/api/2.0/yii-captcha-captchaaction|Yii CaptchaAction]] |